home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_400 / 422_04 / library.doc < prev    next >
Text File  |  1994-03-20  |  183KB  |  6,494 lines

  1.           
  2.           
  3.           
  4.           
  5.           
  6.           
  7.           
  8.           
  9.           
  10.           ===========================================================
  11.                 DDDDD           DDDDD               SSSS
  12.                  D   Dunfield    D   D             S
  13.                  D   D           D   Development    SSSS 
  14.                  D   D           D   D                  Systems
  15.                 DDDDD           DDDDD               SSSS
  16.           ===========================================================
  17.           MM   MM  IIIIIII    CCCC   RRRRRR     OOO             CCCC
  18.           M M M M     I      C    C  R     R   O   O           C    C
  19.           M  M  M     I     C        R     R  O     O         C
  20.           M     M     I     C        RRRRRR   O     O  -----  C
  21.           M     M     I     C        R   R    O     O         C
  22.           M     M     I      C    C  R    R    O   O           C    C
  23.           M     M  IIIIIII    CCCC   R     R    OOO             CCCC
  24.           ===========================================================
  25.     
  26.     
  27.     
  28.     
  29.     
  30.                              A compact 'C' compiler
  31.                                       for
  32.                                  Small Systems.
  33.     
  34.     
  35.                                Library Reference
  36.     
  37.     
  38.     
  39.     
  40.     
  41.                                   Release 3.02
  42.     
  43.                                Revised 03-Jan-94
  44.     
  45.     
  46.     
  47.     
  48.     
  49.     
  50.     
  51.     
  52.     
  53.     
  54.     
  55.     
  56.                        Copyright 1988-1994 Dave Dunfield
  57.                               All rights reserved
  58.     MICRO-C Library                                                  Page: 1
  59.  
  60.  
  61.     1. THE MICRO-C LIBRARIES
  62.     
  63.           The MICRO-C distribution disk includes the 'C'  and  'ASM'  source
  64.        code for a very complete function library which is configured for use
  65.        on an IBM/PC under the MS-DOS operating system. These routines may be
  66.        also be used as "example" programs, providing  insight  into  MICRO-C
  67.        programming techniques.
  68.     
  69.           All functions except for the lowest level I/O routines  are  coded
  70.        in 'C', and should compile on any MICRO-C system. Note that some  low
  71.        level functions in the library are written in 'C' using  still  lower
  72.        level routines. Although this makes the library highly  portable  and
  73.        reduces the number of routines you have to re-write  for  a  specific
  74.        system, the resultant function will be less efficent than  one  which
  75.        directly uses the operating system services.
  76.     
  77.           If you are implementing MICRO-C an a small system  and  intend  to
  78.        use it for serious programming, I strongly recommend that you re-code
  79.        all of the low level library functions in assembly language.
  80.     
  81.           Note that since library routines are often  used  in  applications
  82.        where code size and execution speed are of primary importance, it may
  83.        be desirable to recode some or all of the other library  routines  in
  84.        assembly language as well.
  85.     
  86.           For those who intend to make only casual use of  MICRO-C,  or  who
  87.        wish to experiment with it simply for the  learning  experience,  the
  88.        'C' versions of the low level library functions should be  more  than
  89.        sufficient.
  90.     
  91.           NOTE: If you purchased MICRO-C as  part  of  a  "developers  kit",
  92.        refer to the documentation included with the CPU  support  files  for
  93.        details on the pre-configured library for that CPU, and the functions
  94.        available therein.
  95.     MICRO-C Library                                                  Page: 2
  96.  
  97.  
  98.     
  99.                          +----------------------------+
  100.                          |                            |
  101.                          |  ************************  |
  102.                          |  * The STANDARD library *  |
  103.                          |  ************************  |
  104.                          |                            |
  105.                          +----------------------------+
  106.     
  107.     
  108.     
  109.     
  110.     
  111.     
  112.     
  113.     
  114.     
  115.     
  116.        1.1 STANDARD Library
  117.     
  118.              The library functions described  on  the  following  pages  are
  119.           currently available in the IBM/PC MICRO-C  library  as  "standard"
  120.           functions which are of a general nature, and should be portable to
  121.           most implementations of MICRO-C.
  122.     
  123.              The exact syntax and capabilities of the  system  or  processor
  124.           dependant functions may vary  in  different  implementations,  see
  125.           your  implementation  notes  (READ.ME)  for   details.   Different
  126.           possible forms of such functions are shown using (1), (2), ...  In
  127.           these cases, the form (1) of the function is the one used  in  the
  128.           MS-DOS library.
  129.     ABORT                                                             ABORT
  130.     
  131.     
  132.     
  133.     PROTOTYPE:
  134.     
  135.         abort(char *message)
  136.     
  137.     
  138.     ARGUMENTS:
  139.     
  140.         message - Pointer to message to display
  141.     
  142.     
  143.     RETURN VALUE:
  144.     
  145.         N/A - Function never returns
  146.     
  147.     
  148.     DESCRIPTION:
  149.     
  150.           This function writes the string passed as an argument to  standard
  151.        error, and then terminates the program with a  return  code  of  '-1'
  152.        (Indicating general  failure).  This  provides  a  simple  method  of
  153.        terminating a program on an error condition with a message explaining
  154.        why.
  155.     
  156.     
  157.     EXAMPLES:
  158.     
  159.         abort("Invalid operand\n");
  160.     ABS                                                                 ABS
  161.     
  162.     
  163.     
  164.     PROTOTYPE:
  165.     
  166.         int abs(int number)
  167.     
  168.     
  169.     ARGUMENTS:
  170.     
  171.         number  - Any integer value
  172.     
  173.     
  174.     RETURN VALUE:
  175.     
  176.         The absolute value of "number"
  177.     
  178.     
  179.     DESCRIPTION:
  180.     
  181.           The "abs" function returns the absolute value of the argument.  If
  182.        "number" is a positive value, it is returned unchanged. If  negative,
  183.        the negate of that value is returned (giving a positive result).
  184.     
  185.     
  186.     EXAMPLES:
  187.     
  188.         difference = abs(value1 - value2);
  189.     ATOI                                                               ATOI
  190.     
  191.     
  192.     
  193.     PROTOTYPE:
  194.     
  195.         int atoi(char *string)
  196.     
  197.     
  198.     ARGUMENTS:
  199.     
  200.         string  - Pointer to a string containing a decimal number
  201.     
  202.     
  203.     RETURN VALUE:
  204.     
  205.         16 bit integer value
  206.     
  207.     
  208.     DESCRIPTION:
  209.     
  210.           The "atoi" function converts an ASCII string containing  a  signed
  211.        decimal number (-32768 to 32767) to a 16 bit value which is returned.
  212.        An unsigned number of the range (0 to 65535) may also  be  used,  and
  213.        the result if assigned to an "unsigned" variable will be correct.
  214.     
  215.     
  216.     EXAMPLES:
  217.     
  218.         value = atoi("1234");
  219.         value = atoi("-1");
  220.     CD                                                                   CD
  221.     
  222.     
  223.     
  224.     PROTOTYPE:
  225.     
  226.         int cd(char *pathname)
  227.     
  228.     
  229.     ARGUMENTS:
  230.     
  231.         pathname- Name of directory to make current
  232.     
  233.     
  234.     RETURN VALUE:
  235.     
  236.         0 if successful, otherwise an operating system error code
  237.     
  238.     
  239.     DESCRIPTION:
  240.     
  241.           This function sets the "current" directory, causing all subsequent
  242.        file references which do not explicitly indicate a directory path  to
  243.        access the path specified by "pathname".
  244.     
  245.     
  246.     EXAMPLES:
  247.     
  248.         cd("/mc/c_source");     /* UNIX */
  249.         cd("\\mc\\l_source");   /* MS-DOS */
  250.     CLOSE                                                             CLOSE
  251.     
  252.     
  253.     
  254.     PROTOTYPE:
  255.     
  256.         close(HANDLE fh);
  257.     
  258.     
  259.     ARGUMENTS:
  260.     
  261.         fh      - File handle of an open file
  262.     
  263.     
  264.     RETURN VALUE:
  265.     
  266.         None
  267.     
  268.     
  269.     DESCRIPTION:
  270.     
  271.           This function closes a file  which  was  previously  opened  using
  272.        "open".
  273.     
  274.     
  275.     EXAMPLES:
  276.     
  277.         close(fh);
  278.     CONCAT                                                           CONCAT
  279.     
  280.     
  281.     
  282.     PROTOTYPE:
  283.     
  284.         register concat(char *dest, char *source, ...)
  285.     
  286.     
  287.     ARGUMENTS:
  288.     
  289.         dest    - Pointer to destination string
  290.         source  - Pointer to source string
  291.         ...     - Additional sources may be given
  292.     
  293.     
  294.     RETURN VALUE:
  295.     
  296.         None
  297.     
  298.     
  299.     DESCRIPTION:
  300.     
  301.           The "concat" function concatinates the given source  strings  into
  302.        one destination string. The destination string must be  large  enough
  303.        to hold all of the source strings plus the string  terminator  (zero)
  304.        byte. No value is returned.
  305.     
  306.           NOTE: This function uses a variable number of arguments, and  must
  307.        be declared as "register" (See "stdio.h").
  308.     
  309.     
  310.     EXAMPLES:
  311.     
  312.         concat(filename,"/tmp/", input_name);
  313.     CREATE                                                           CREATE
  314.     
  315.     
  316.     
  317.     PROTOTYPE:
  318.     
  319.         int create(char *pathname, int attrs)
  320.     
  321.     
  322.     
  323.     ARGUMENTS:
  324.     
  325.         pathname- Name of file to create
  326.         attrs   - Attributes for new file
  327.     
  328.     
  329.     RETURN VALUE:
  330.     
  331.         0 if successful, otherwise an operating system error code
  332.     
  333.     
  334.     DESCRIPTION:
  335.     
  336.           The "create" function creates a new file with the specified system
  337.        attributes.
  338.     
  339.           The meaning of the individual bits in the "attrs" value is  system
  340.        dependant, and is defined in the "file.h" header file.
  341.     
  342.     
  343.     EXAMPLES:
  344.     
  345.         create("temp", HIDDEN);
  346.     DELETE                                                           DELETE
  347.     
  348.     
  349.     
  350.     PROTOTYPE:
  351.     
  352.         int delete(char *pathname)
  353.     
  354.     
  355.     
  356.     ARGUMENTS:
  357.     
  358.         pathname- Name of file to delete
  359.     
  360.     
  361.     RETURN VALUE:
  362.     
  363.         0 if successful, otherwise an operating system error code
  364.     
  365.     
  366.     DESCRIPTION:
  367.     
  368.           The "delete" function removes an existing file from the disk.  Any
  369.        disk space occupied by the file is released.
  370.     
  371.     
  372.     EXAMPLES:
  373.     
  374.         delete("temp");
  375.     EXIT                                                               EXIT
  376.     
  377.     
  378.     
  379.     PROTOTYPE:
  380.     
  381.         exit(int rc)
  382.     
  383.     
  384.     ARGUMENTS:
  385.     
  386.         rc      - Termination return code
  387.     
  388.     
  389.     RETURN VALUE:
  390.     
  391.         N/A - Function never returns
  392.     
  393.     
  394.     DESCRIPTION:
  395.     
  396.           This function terminates the execution of the program and passes a
  397.        specific return code back to the  operating  system.  A  return  code
  398.        value of zero is used  to  indicate  successful  program  completion.
  399.        Non-zero return code values may be used to indicate a particular type
  400.        of failure. A value of '-1' is often used to indicate a  non-specific
  401.        failure. Note that  the  "rc"  value  is  very  system  specific,  in
  402.        particular, some systems support only 8 bit return codes,  so  values
  403.        which are greater than 255 should be avoided.
  404.     
  405.     
  406.     EXAMPLES:
  407.     
  408.         exit(0);        /* success */
  409.         exit(-1);       /* failure */
  410.     FCLOSE                                                           FCLOSE
  411.     
  412.     
  413.     
  414.     PROTOTYPE:
  415.     
  416.         fclose(FILE *fp);
  417.     
  418.     
  419.     ARGUMENTS:
  420.     
  421.         fp      - File pointer to an open file
  422.     
  423.     
  424.     RETURN VALUE:
  425.     
  426.         None
  427.     
  428.     
  429.     DESCRIPTION:
  430.     
  431.           This function closes a file  which  was  previously  opened  using
  432.        "fopen". The I/O buffer space used by the file is  released.  In  the
  433.        case of a file open for write ('w'), the last disk buffer is  flushed
  434.        and written to disk.
  435.     
  436.     
  437.     EXAMPLES:
  438.     
  439.         fclose(fp);
  440.     FFLUSH                                                           FFLUSH
  441.     
  442.     
  443.     
  444.     PROTOTYPE:
  445.     
  446.         fflush(FILE *fp)
  447.     
  448.     
  449.     ARGUMENTS:
  450.     
  451.         fp       File pointer to an open file
  452.     
  453.     
  454.     RETURN VALUE:
  455.     
  456.         0 if successful, otherwise an operating system error code
  457.     
  458.     
  459.     DESCRIPTION:
  460.     
  461.           The "fflush" function flushes the I/O buffers for the  given  open
  462.        file. If the file is opened for WRITE, this causes any data remaining
  463.        in a partially filled output buffer to be written.  If  the  file  is
  464.        opened for READ, this has the effect of throwing away any data  which
  465.        is pending in the input buffer.
  466.     
  467.     
  468.     EXAMPLES:
  469.     
  470.         fputs("Enter you name?", stdout);
  471.         fflush(stdout);         /* Make sure prompt is output */
  472.         fgets(name, 80, stdin);
  473.     FGETS                                                             FGETS
  474.     
  475.     
  476.     
  477.     PROTOTYPE:
  478.     
  479.         char *fgets(char *buffer, int size, FILE *fp)
  480.     
  481.     
  482.     ARGUMENTS:
  483.     
  484.         buffer  - Pointer to string to receive line
  485.         size    - Maximum size of line to read
  486.         fp      - File pointer to an input file
  487.     
  488.     
  489.     RETURN VALUE:
  490.     
  491.         Pointer to "buffer", or 0 if end of file
  492.     
  493.     
  494.     DESCRIPTION:
  495.     
  496.           The "fgets" function reads characters  from  the  specified  input
  497.        file, and places them in the character  buffer  until  one  of  three
  498.        things happens:
  499.     
  500.           1) A NEWLINE character is encountered.
  501.     
  502.           2) The END of the file is encountered.
  503.     
  504.           3) The limit of "size" character is read.
  505.     
  506.           The string is terminated with the standard  NULL  (00)  character.
  507.        The trailing NEWLINE '\n' character is NOT  included  in  the  output
  508.        buffer.
  509.     
  510.     
  511.     EXAMPLES:
  512.     
  513.         fgets(input_line, 80, input_file);
  514.     FIND_FIRST                                                   FIND_FIRST
  515.     
  516.     
  517.     
  518.     PROTOTYPE:
  519.     
  520.         int find_first(char *pattern, int mattrs, char name[], int &sizeh,
  521.                        int &sizel, int &attrs, int &time, int &date)
  522.     
  523.     
  524.     ARGUMENTS:
  525.     
  526.         pattern - File name pattern to match
  527.         mattrs  - File attributes to match
  528.         name    - Address of string to receive file name
  529.         &sizeh  - Address of int to receive high word of size
  530.         &sizel  - Address of int to receive low word of size
  531.         &attrs  - Address of int to receive attributes
  532.         &time   - Address of int to receive time stamp
  533.         &date   - Address of int to receive date stamp
  534.     
  535.     
  536.     RETURN VALUE:
  537.     
  538.         0 if successful, otherwise an operating system error code
  539.     
  540.     
  541.     DESCRIPTION:
  542.     
  543.           This function locates the first file on the disk which matches the
  544.        given pattern. The "mattrs" field specifies  any  special  attributes
  545.        the files must have  in  order  to  be  matched,  use  0  for  normal
  546.        directory searches.
  547.     
  548.           Subsequent files may be located using the "find_next" function.
  549.     
  550.           The above function prototype describes the  MS-DOS  implementation
  551.        of the function. With other operating systems, the function may  have
  552.        slightly  different  parameters,   due   to   differing   information
  553.        available. See your implementation notes.
  554.     
  555.     
  556.     EXAMPLES:
  557.     
  558.         if(find_first(pattern, 0, name, &sh, &sl, &a, &t, &d))
  559.             abort("No matching files found\n");
  560.     FIND_NEXT                                                     FIND_NEXT
  561.     
  562.     
  563.     
  564.     PROTOTYPE:
  565.     
  566.         int find_next(char name[], int &sizeh, int &sizel, int &attrs,
  567.                       int &time, int &date)
  568.     
  569.     
  570.     ARGUMENTS:
  571.     
  572.         name    - Address of string to receive file name
  573.         &sizeh  - Address of int to receive high word of size
  574.         &sizel  - Address of int to receive low word of size
  575.         &attrs  - Address of int to receive attributes
  576.         &time   - Address of int to receive time stamp
  577.         &date   - Address of int to receive date stamp
  578.     
  579.     
  580.     RETURN VALUE:
  581.     
  582.         0 if successful, otherwise an operating system error code
  583.     
  584.     
  585.     DESCRIPTION:
  586.     
  587.           The function must be preceeded by a call to "find_first", and will
  588.        locate the next file on  the  disk  which  matches  the  pattern  and
  589.        attributes given to that function call.
  590.     
  591.           The above function prototype describes the  MS-DOS  implementation
  592.        of the function. With other operating systems, the function may  have
  593.        slightly  different  parameters,   due   to   differing   information
  594.        available. See your implementation notes.
  595.     
  596.     
  597.     EXAMPLES:
  598.     
  599.         do
  600.             printf("%s\n", name);
  601.         while(!find_next(name, &sh, &sl, &a, &t, &d));
  602.     FOPEN                                                             FOPEN
  603.     
  604.     
  605.     
  606.     PROTOTYPE:
  607.     
  608.         FILE *fopen(char *filename, char *options)
  609.     
  610.     
  611.     ARGUMENTS:
  612.     
  613.         filename- Name of the file to open
  614.         options - String containing open options:
  615.                     'a' - Append to file (must use with 'w')
  616.                     'b' - Binary mode (default is text)
  617.                     'q' - Quit { exit(-1) } on failure
  618.                     'r' - Open file for read
  619.                     'v' - Issue error message on failure
  620.                     'w' - Open file for write
  621.     
  622.     
  623.     RETURN VALUE:
  624.     
  625.         File pointer to the file buffer for the open file
  626.         Zero (0) if file could not be opened
  627.     
  628.     
  629.     DESCRIPTION:
  630.     
  631.           This function opens a file for  buffered  input  ('r')  or  output
  632.        ('w'), allowing subsequent I/O operations to read or write the  file.
  633.        If the 'b' option is NOT included, the file is assumed to be  a  TEXT
  634.        file, and appropriate translations  are  made  for  NEWLINE  and  EOF
  635.        interpretation.
  636.     
  637.           The size of the I/O buffer used is established by "fopen" from the
  638.        external variable 'IOB_size',  which  has  a  default  value  of  256
  639.        (bytes). This variable is defined in the 'file.h'  header  file,  and
  640.        may be modified prior to calling this function if you wish to  use  a
  641.        different buffer size.
  642.     
  643.           One I/O buffer is allocated from the heap for each open file. When
  644.        using a large IOB_size value, you must be careful not to consume more
  645.        memory than is available.
  646.     
  647.     
  648.     EXAMPLES:
  649.     
  650.         fp = fopen("input_file", "r");
  651.         fp = fopen("input_file", "rvq");
  652.         IOB_size = 1024*10;         /* Set up a 10K buffer */
  653.         fp = fopen("output_file", "wb");
  654.     FPRINTF                                                         FPRINTF
  655.     
  656.     
  657.     
  658.     PROTOTYPE:
  659.     
  660.         register fprintf(FILE *fp, char *format, arg, ...)
  661.     
  662.     
  663.     ARGUMENTS:
  664.     
  665.         fp      - File pointer to an output file
  666.         format  - Pointer to format string
  667.         arg     - Argument as determined by format string
  668.         ...     - Additional arguments may be required
  669.     
  670.     
  671.     RETURN VALUE:
  672.     
  673.         None
  674.     
  675.     
  676.     DESCRIPTION:
  677.     
  678.           This routine performs a formatted print to  a  file  specified  by
  679.        'fp'. The 'format' string is written to the file with  the  arguments
  680.        substituted for special "conversion  characters".  These  "conversion
  681.        characters" are identified by a preceeding '%', and may be one of the
  682.        following:
  683.     
  684.                     b       - Binary number
  685.                     c       - Character
  686.                     d       - Decimal (signed) number
  687.                     o       - Octal number
  688.                     s       - String
  689.                     u       - Unsigned decimal number
  690.                     x       - Hexidecimal number
  691.                     %       - A single percent sign (No argument used)
  692.     
  693.           A numeric "field width" specifier may be placed in between the '%'
  694.        and the conversion character, in which case the value will be  output
  695.        in a field of that width. If the "field width" is a negative  number,
  696.        the output will be left justified in the field, otherwise it is right
  697.        justified. If the field width contains a leading '0', then the output
  698.        field will be padded with zero's, otherwise spaces are used.
  699.     
  700.           If no "field width" is given, the output  is  free  format,  using
  701.        only as much space as required.
  702.     
  703.           NOTE: This function uses a variable number of arguments, and  must
  704.        be declared as "register" (See "stdio.h").
  705.     
  706.     
  707.     EXAMPLES:
  708.     
  709.         fprintf(stderr,"Filename='%s'\n", filename);
  710.         fprintf(stdout,"Address=%04x\n", address);
  711.         fprintf(outfile,"Amount: $%3u.%02u\n", amount / 100, amount % 100);
  712.     FPUTS                                                             FPUTS
  713.     
  714.     
  715.     
  716.     PROTOTYPE:
  717.     
  718.         fputs(char *string, FILE *fp)
  719.     
  720.     
  721.     ARGUMENTS:
  722.     
  723.         string  - Pointer to a character string
  724.         fp      - FIle pointer to output file
  725.     
  726.     
  727.     RETURN VALUE:
  728.     
  729.         0 if successful, otherwise an operating system error code
  730.     
  731.     
  732.     DESCRIPTION:
  733.     
  734.           The "fputs" function writes the specified string to the  indicated
  735.        output file. The zero terminating the string is NOT written.
  736.     
  737.     
  738.     EXAMPLES:
  739.     
  740.         fputs("Text message", output_file);
  741.     FREAD                                                             FREAD
  742.     
  743.     
  744.     
  745.     PROTOTYPE:
  746.     
  747.         int fread(char *buffer, int size, FILE *fp)
  748.     
  749.     
  750.     ARGUMENTS:
  751.     
  752.         buffer  - Pointer to buffer to receive data
  753.         size    - Number of bytes to read
  754.         fp      - File pointer to an input file
  755.     
  756.     
  757.     RETURN VALUE:
  758.     
  759.         Number of bytes read from file
  760.     
  761.     
  762.     DESCRIPTION:
  763.     
  764.           This function reads a block of data from a file and places  it  in
  765.        memory at the address of "buffer". Data will be read in  either  TEXT
  766.        or BINARY form, depending on how the file was opened. If  the  number
  767.        of bytes returned is less than the number of bytes requested,  either
  768.        the end of the file was encountered or an error condition occured (in
  769.        which case the value will be zero).
  770.     
  771.     
  772.     EXAMPLES:
  773.     
  774.         fread(block, 512, input_fp);
  775.     FREE                                                               FREE
  776.     
  777.     
  778.     
  779.     PROTOTYPE:
  780.     
  781.         free(char *ptr)
  782.     
  783.     
  784.     ARGUMENTS:
  785.     
  786.         ptr     - Pointer to a previously allocated memory block
  787.     
  788.     
  789.     RETURN VALUE:
  790.     
  791.         None
  792.     
  793.     
  794.     DESCRIPTION:
  795.     
  796.           The "free" function releases (de-allocates) a block of memory that
  797.        was obtained via a call to "malloc", and returns it to the heap. This
  798.        makes it available for use by other memory allocations.
  799.     
  800.     
  801.     EXAMPLES:
  802.     
  803.         if(!(ptr = malloc(BUFSIZ)))     /* Allocate a temporary buffer */
  804.             abort("Not enough memory");
  805.         do {                            /* Copy the file over */
  806.             size = fread(ptr, BUFSIZ, in_fp);
  807.             fwrite(ptr, size, out_fp); }
  808.         while(size == BUFSIZ);
  809.         free(ptr);                      /* Release temporary buffer */
  810.     FSCANF                                                           FSCANF
  811.     
  812.     
  813.     
  814.     PROTOTYPE:
  815.     
  816.         register int fscanf(FILE *fp, char *format, &arg, ...)
  817.     
  818.     
  819.     ARGUMENTS:
  820.     
  821.         fp      - File pointer to an input file
  822.         format  - Pointer to format string
  823.         arg     - Argument as determined by format string
  824.         ...     - Additional arguments may be required
  825.     
  826.     
  827.     RETURN VALUE:
  828.     
  829.         The number of successful matches
  830.         EOF (-1) if end of file or an error condition occurs
  831.     
  832.     
  833.     DESCRIPTION:
  834.     
  835.           This routine reads a line from the specified file and scans it for
  836.        specific values which  are  then  assigned  to  the  passed  argument
  837.        addresses. The types of values  scanned  are  determined  by  special
  838.        "conversion characters" within the "format" string. These "conversion
  839.        characters" are identified by a preceeding '%', and may be one of the
  840.        following:
  841.     
  842.                     b       - Binary number
  843.                     c       - Character
  844.                     d       - Decimal (signed) number
  845.                     o       - Octal number
  846.                     s       - String
  847.                     u       - Unsigned decimal number
  848.                     x       - Hexidecimal number
  849.                     %       - A single percent sign (No argument used)
  850.     
  851.           Before scanning for any value other than '%c', any leading "space"
  852.        or "tab" characters in the input line are automatically flushed.
  853.     
  854.           Scanning of a particular value type will terminate when either the
  855.        end of  the  line  or  a  non-applicible  character  is  encountered.
  856.        Scanning of strings (%s) stops with a "space" or "tab" character, and
  857.        the stored string will be zero terminated.
  858.     
  859.           A numeric "field width" specifier may be placed in between the '%'
  860.        and the conversion character, in which case  scanning  of  the  value
  861.        will  also  terminate  if  that  many  input  characters  have   been
  862.        processed.
  863.     
  864.           Scanning  for  characters  (%c)  assumes  a  "field  width"  of  1
  865.        character unless otherwise specified. If a field width is  specified,
  866.        the output is assumed to be  a  string,  and  a  zero  terminator  is
  867.        appended.
  868.     
  869.     
  870.     
  871.     
  872.     
  873.     
  874.     
  875.     
  876.     
  877.     
  878.           Any other (non-conversion) characters in the  format  string  will
  879.        cause the next character in the input string which is not  a  "space"
  880.        or "tab" to be skipped if it matches that character.
  881.     
  882.           Any variable values from the input line  which  are  not  required
  883.        must be cleared by scanning them into a "dummy" variable.
  884.     
  885.           The most common mistake when using "fscanf" is forgetting  to  use
  886.        the '&'  operator  with  a  simple  variable  argument.  This  causes
  887.        "fscanf" to store the value INDIRECTLY at the  address  contained  in
  888.        that variable (Similar to  using  '*'  with  a  pointer)  instead  of
  889.        storing the value into the actual variable  itself.  Arguments  which
  890.        are array names do not require the '&' operator, since the address of
  891.        the array is already generated by reference to its name.
  892.     
  893.           Unlike "fscanf" in most  other  compiler  libraries,  the  MICRO-C
  894.        function always reads and scans a single line from the input file.
  895.     
  896.           NOTE: This function uses a variable number of arguments, and  must
  897.        be declared as "register".
  898.     
  899.     
  900.     EXAMPLES:
  901.     
  902.         if(fscanf(infile,"%s %s %u", first_name, last_name, &age) != 3)
  903.             abort("Error in user record\n");
  904.     FSEEK                                                             FSEEK
  905.     
  906.     
  907.     
  908.     PROTOTYPE:
  909.     
  910.         (1) int fseek(FILE *fp, int h_offset, unsigned l_offset, int mode)
  911.         (2) int fseek(FILE *fp, int offset, mode)
  912.     
  913.     
  914.     ARGUMENTS:
  915.     
  916.         fp      - File pointer to an open file
  917.         h_offset- Highest 16 bits of offset value
  918.         l_offset- Lowest 16 bits of offset value
  919.         offset  - 16 bit offset value
  920.         mode    - Type of seek
  921.                     0 = Absolute from start of file
  922.                     1 = Signed offset from current position
  923.                     2 = Signed offset from end of file
  924.     
  925.     
  926.     RETURN VALUE:
  927.     
  928.         0 if successful, otherwise an operating system error code
  929.     
  930.     
  931.     DESCRIPTION:
  932.     
  933.           This function positions the operating system internal pointer into
  934.        a file so that any read or write will take  place  at  the  specified
  935.        position in the file.
  936.     
  937.           Most operating systems which support files of > 64K bytes in  size
  938.        will support form (1) of the function, using both high and low offset
  939.        values.
  940.     
  941.           Smaller operating  systems  may  only  support  form  (2)  of  the
  942.        function, allowing seeking of only +/- 32K bytes.
  943.     
  944.           Also, some implementations may not support  all  "modes",  or  may
  945.        only allow unsigned (positive) offsets.
  946.     
  947.     
  948.     EXAMPLES:
  949.     
  950.         fseek(in_file, 0, 2);   /* Advance to end of file */
  951.     FTELL                                                             FTELL
  952.     
  953.     
  954.     
  955.     PROTOTYPE:
  956.     
  957.         (1) int ftell(FILE *fp, int &h_offset, unsigned &l_offset)
  958.         (2) int ftell(FILE *fp, int &offset)
  959.     
  960.     
  961.     ARGUMENTS:
  962.     
  963.         fp      - File pointer to an open file
  964.         h_offset- Address of int to receive high word of offset
  965.         l_offset- Address of int to receive low word of offset
  966.         offset  - Address of int to receive offset
  967.     
  968.     
  969.     RETURN VALUE:
  970.     
  971.         0 if successful, otherwise an operating system error code
  972.     
  973.     
  974.     DESCRIPTION:
  975.     
  976.           This function gets the current read/write position within a  file.
  977.        The position returned indicates the absolute character (byte)  offset
  978.        from the start of the file where the next read  or  write  will  take
  979.        place.
  980.     
  981.           Most operating systems which support files of > 64K bytes in  size
  982.        will support form (1) of the function, returning both  high  and  low
  983.        offset values.
  984.     
  985.           Smaller operating  systems  may  only  support  form  (2)  of  the
  986.        function,  allowing  access  to  only  the  first   65535   character
  987.        positions.
  988.     
  989.     
  990.     EXAMPLES:
  991.     
  992.         ftell(fp, &oldh, &oldl);    /* Save file position */
  993.             . . .                   /* Perform some operations on the file */
  994.         fseek(fp, oldh, oldl, 0);   /* Return to previous position */
  995.     FWRITE                                                           FWRITE
  996.     
  997.     
  998.     
  999.     PROTOTYPE:
  1000.     
  1001.         int fwrite(char *block, int size, FILE *fp)
  1002.     
  1003.     
  1004.     ARGUMENTS:
  1005.     
  1006.         block   - Pointer to a block of data to write
  1007.         size    - Number of bytes to write
  1008.         fp      - File pointer to an output file
  1009.     
  1010.     
  1011.     RETURN VALUE:
  1012.     
  1013.         The number of bytes written to the file
  1014.     
  1015.     
  1016.     DESCRIPTION:
  1017.     
  1018.           This function writes a block of data to the  indicated  file  from
  1019.        memory at the specified address. Data is written in  either  TEXT  or
  1020.        BINARY mode, depending on how the  file  was  opened.  If  the  value
  1021.        returned is less than the value of the "size" parameter,  some  error
  1022.        condition has occured (Such as disk full).
  1023.     
  1024.     
  1025.     EXAMPLES:
  1026.     
  1027.         if(fwrite(buffer, 100, fp) < 100)
  1028.             abort("File write error\n");
  1029.     GETC                                                               GETC
  1030.     
  1031.     
  1032.     
  1033.     PROTOTYPE:
  1034.     
  1035.         int getc(FILE *fp)
  1036.     
  1037.     
  1038.     ARGUMENTS:
  1039.     
  1040.         fp      - File pointer to an input file
  1041.     
  1042.     
  1043.     RETURN VALUE:
  1044.     
  1045.         Value of a character read from the file (0-255)
  1046.         EOF (-1) if end of file or an error condition occurs
  1047.     
  1048.     
  1049.     DESCRIPTION:
  1050.     
  1051.           This function reads a single character from  an  input  file,  and
  1052.        returns it as a positive value in the range of 0 to 255.  A  full  16
  1053.        bit value is returned, allowing the  end  of  file  condition  to  be
  1054.        distinct from the character value 255.
  1055.     
  1056.     
  1057.     EXAMPLES:
  1058.     
  1059.         if((c = getc(input_file)) == EOF)
  1060.             abort("End of file encountered\n");
  1061.     GETDIR                                                           GETDIR
  1062.     
  1063.     
  1064.     
  1065.     PROTOTYPE:
  1066.     
  1067.         int getdir(char pathname[])
  1068.     
  1069.     
  1070.     ARGUMENTS:
  1071.     
  1072.         pathname- Address of string to receive directory path
  1073.     
  1074.     
  1075.     RETURN VALUE:
  1076.     
  1077.         0 if successful, otherwise an operating system error code
  1078.     
  1079.     
  1080.     DESCRIPTION:
  1081.     
  1082.           This function retreives from the system the name of the  "current"
  1083.        directory path.
  1084.     
  1085.           The "pathname" string must be long  enough  to  hold  the  largest
  1086.        pathname supported by the system, as  indicated  by  the  "PATH_SIZE"
  1087.        definition in the "file.h" header file.
  1088.     
  1089.     
  1090.     EXAMPLES:
  1091.     
  1092.         getdir(¤t_dir);
  1093.     GETENV                                                           GETENV
  1094.     
  1095.     
  1096.     
  1097.     PROTOTYPE:
  1098.     
  1099.         int getenv(char *ename, char *dest)
  1100.     
  1101.     
  1102.     ARGUMENTS:
  1103.     
  1104.         ename   - String containing name of environment variable
  1105.         dest    - Buffer to receive variable string value
  1106.     
  1107.     
  1108.     RETURN VALUE:
  1109.     
  1110.         1 if environment variable was found, 0 if not.
  1111.     
  1112.     
  1113.     DESCRIPTION:
  1114.     
  1115.           The GETENV function gets the value of a variable in  the  programs
  1116.        environment, and returns it as a string. If the environment  variable
  1117.        is not found, zero is returned, and the destination buffer is set  to
  1118.        a null (zero length) string.
  1119.     
  1120.           Use of this  function  allows  a  programs  fixed  parameters  and
  1121.        options to be specified once in environment variables, which may then
  1122.        be extracted by the program, eliminating the need  to  specify  those
  1123.        values every time the program is executed.
  1124.     
  1125.           When operating  MICRO-C  under  operating  systems  which  do  not
  1126.        support environment variables, this function will not be available.
  1127.     
  1128.     
  1129.     EXAMPLES:
  1130.     
  1131.         if(!getenv("COMSPEC", command))
  1132.             abort("No command processor defined\n");
  1133.     IN                                                                   IN
  1134.     
  1135.     
  1136.     
  1137.     PROTOTYPE:
  1138.     
  1139.         int in(unsigned port)
  1140.     
  1141.     
  1142.     ARGUMENTS:
  1143.     
  1144.         port    - I/O port address
  1145.     
  1146.     
  1147.     RETURN VALUE:
  1148.     
  1149.         The 8 bit value read from the given I/O port address
  1150.     
  1151.     
  1152.     DESCRIPTION:
  1153.     
  1154.           The "in" function reads and returns a byte (8 bits)  from  an  I/O
  1155.        port as an integer value between 0 and 255.
  1156.     
  1157.           The valid range of values for "port" depends on  the  I/O  address
  1158.        space of the processor.
  1159.     
  1160.           This function is not provided for processors which do not  support
  1161.        a separate I/O address space.
  1162.     
  1163.     
  1164.     EXAMPLES:
  1165.     
  1166.         while(in(0));   /* Wait for flag to clear */
  1167.     INW                                                                 INW
  1168.     
  1169.     
  1170.     
  1171.     PROTOTYPE:
  1172.     
  1173.         int inw(unsigned port)
  1174.     
  1175.     
  1176.     ARGUMENTS:
  1177.     
  1178.         port    - I/O port address
  1179.     
  1180.     
  1181.     RETURN VALUE:
  1182.     
  1183.         The 16 bit value read from the given I/O port address
  1184.     
  1185.     
  1186.     DESCRIPTION:
  1187.     
  1188.           The "inw" function reads and returns a word (16 bits) from an  I/O
  1189.        port as an integer value between 0 and 65535 (-1).
  1190.     
  1191.           The valid range of values for "port" depends on  the  I/O  address
  1192.        space of the processor.
  1193.     
  1194.           This function is not provided for processors which do not  support
  1195.        a separate I/O address space.
  1196.     
  1197.     
  1198.     EXAMPLES:
  1199.     
  1200.         var = inw(0);
  1201.     ISASCII                                                         ISASCII
  1202.     
  1203.     
  1204.     
  1205.     PROTOTYPE:
  1206.     
  1207.         int isascii(int c)
  1208.     
  1209.     
  1210.     ARGUMENTS:
  1211.     
  1212.         c       - Any character value
  1213.     
  1214.     
  1215.     RETURN VALUE:
  1216.     
  1217.         1 if 'c' is an ASCII character
  1218.         0 if 'c' is not an ASCII character
  1219.     
  1220.     
  1221.     DESCRIPTION:
  1222.     
  1223.           Returns TRUE (1) if the passed character  'c'  is  a  valid  ASCII
  1224.        character (0x00-0xFF), otherwise FALSE (0) is returned.
  1225.     
  1226.     
  1227.     EXAMPLES:
  1228.     
  1229.         if(!isascii(*ptr))
  1230.             abort("Invalid character data");
  1231.     ISALNUM                                                         ISALNUM
  1232.     
  1233.     
  1234.     
  1235.     PROTOTYPE:
  1236.     
  1237.         int isalnum(char c)
  1238.     
  1239.     
  1240.     ARGUMENTS:
  1241.     
  1242.         c       - Any character value
  1243.     
  1244.     
  1245.     RETURN VALUE:
  1246.     
  1247.         1 if 'c' is alphabetic or numeric
  1248.         0 if 'c' is not alphabetic or numeric
  1249.     
  1250.     
  1251.     DESCRIPTION:
  1252.     
  1253.           Returns  TRUE  (1)  if  the  passed  character  'c'  is  an  ASCII
  1254.        alphabetic letter in either upper or  lower  case  or  if  'c'  is  a
  1255.        numeric digit, otherwise FALSE (0) is returned.
  1256.     
  1257.     
  1258.     EXAMPLES:
  1259.     
  1260.         while(isalnum(*ptr))        /* Copy over symbol name */
  1261.             *name++ = *ptr++;
  1262.     ISALPHA                                                         ISALPHA
  1263.     
  1264.     
  1265.     
  1266.     PROTOTYPE:
  1267.     
  1268.         int isalpha(char c)
  1269.     
  1270.     
  1271.     ARGUMENTS:
  1272.     
  1273.         c       - Any character value
  1274.     
  1275.     
  1276.     RETURN VALUE:
  1277.     
  1278.         1 if 'c' is alphabetic
  1279.         0 if 'c' is not alphabetic
  1280.     
  1281.     
  1282.     DESCRIPTION:
  1283.     
  1284.           Returns  TRUE  (1)  if  the  passed  character  'c'  is  an  ASCII
  1285.        alphabetic letter in either upper or lower case, otherwise FALSE  (0)
  1286.        is returned.
  1287.     
  1288.     
  1289.     EXAMPLES:
  1290.     
  1291.         flag = isalpha(input_char);
  1292.     ISCNTRL                                                         ISCNTRL
  1293.     
  1294.     
  1295.     
  1296.     PROTOTYPE:
  1297.     
  1298.         int iscntrl(char c)
  1299.     
  1300.     
  1301.     ARGUMENTS:
  1302.     
  1303.         c       - Any character value
  1304.     
  1305.     
  1306.     RETURN VALUE:
  1307.     
  1308.         1 if 'c' is a "control" character
  1309.         0 if 'c' is not a "control" character
  1310.     
  1311.     
  1312.     DESCRIPTION:
  1313.     
  1314.           Returns TRUE (1) is the passed character 'c' is an ASCII "control"
  1315.        character (0x00-0x1F or 0x7F), otherwise FALSE (0) is returned.
  1316.     
  1317.     
  1318.     EXAMPLES:
  1319.     
  1320.         putc(iscntrl(c) ? '.' : c, stdout); /* Display controls as '.' */
  1321.     ISDIGIT                                                         ISDIGIT
  1322.     
  1323.     
  1324.     
  1325.     PROTOTYPE:
  1326.     
  1327.         int isdigit(char c)
  1328.     
  1329.     
  1330.     ARGUMENTS:
  1331.     
  1332.         c       - Any character value
  1333.     
  1334.     
  1335.     RETURN VALUE:
  1336.     
  1337.         1 if 'c' is numeric
  1338.         0 if 'c' is not numeric
  1339.     
  1340.     
  1341.     DESCRIPTION:
  1342.     
  1343.           Returns TRUE (1) is the passed character 'c'  is  an  ASCII  digit
  1344.        ('0'-'9'), otherwise FALSE (0) is returned.
  1345.     
  1346.     
  1347.     EXAMPLES:
  1348.     
  1349.         value = 0;
  1350.         while(isdigit(*ptr))
  1351.             value = (value * 10) + (*ptr++ - '0');
  1352.     ISGRAPH                                                         ISGRAPH
  1353.     
  1354.     
  1355.     
  1356.     PROTOTYPE:
  1357.     
  1358.         int isgraph(char c)
  1359.     
  1360.     
  1361.     ARGUMENTS:
  1362.     
  1363.         c       - Any character value
  1364.     
  1365.     
  1366.     RETURN VALUE:
  1367.     
  1368.         1 if 'c' is a non-space printable character
  1369.         0 if 'c' is a space or not printable
  1370.     
  1371.     
  1372.     DESCRIPTION:
  1373.     
  1374.           Returns TRUE (1) if the passed character 'c' is a printable  ASCII
  1375.        character other than  a  space  character,  otherwise  FALSE  (0)  is
  1376.        returned.
  1377.     
  1378.     
  1379.     EXAMPLES:
  1380.     
  1381.         putc(isgraph(c) ? c : '.', stdout);
  1382.     ISLOWER                                                         ISLOWER
  1383.     
  1384.     
  1385.     
  1386.     PROTOTYPE:
  1387.     
  1388.         int islower(char c)
  1389.     
  1390.     
  1391.     ARGUMENTS:
  1392.     
  1393.         c       - Any character value
  1394.     
  1395.     
  1396.     RETURN VALUE:
  1397.     
  1398.         1 if 'c' is lower case alphabetic
  1399.         0 if 'c' is not lower case alphabetic
  1400.     
  1401.     
  1402.     DESCRIPTION:
  1403.     
  1404.           Returns  TRUE  (1)  if  the  passed  character  'c'  is  an  ASCII
  1405.        alphabetic letter of lower case, otherwise FALSE (0) is returned.
  1406.     
  1407.     
  1408.     EXAMPLES:
  1409.     
  1410.         flag = islower(input_char);
  1411.     ISPRINT                                                         ISPRINT
  1412.     
  1413.     
  1414.     
  1415.     PROTOTYPE:
  1416.     
  1417.         int isprint(char c)
  1418.     
  1419.     
  1420.     ARGUMENTS:
  1421.     
  1422.         c       - Any character value
  1423.     
  1424.     
  1425.     RETURN VALUE:
  1426.     
  1427.         1 if 'c' is a printable character
  1428.         0 if 'c' is not printable
  1429.     
  1430.     
  1431.     DESCRIPTION:
  1432.     
  1433.           Returns TRUE (1) if the passed character 'c' is a printable  ASCII
  1434.        character (0x20-0xFE), otherwise FALSE (0) is returned.
  1435.     
  1436.     
  1437.     EXAMPLES:
  1438.     
  1439.         putc(isprint(c) ? c : '.', stdout);
  1440.     ISPUNCT                                                         ISPUNCT
  1441.     
  1442.     
  1443.     
  1444.     PROTOTYPE:
  1445.     
  1446.         int ispunct(char c)
  1447.     
  1448.     
  1449.     ARGUMENTS:
  1450.     
  1451.         c       - Any character value
  1452.     
  1453.     
  1454.     RETURN VALUE:
  1455.     
  1456.         1 if 'c' is a printable non-alphanumeric character
  1457.         0 if 'c' is not printable or alphanumeric
  1458.     
  1459.     
  1460.     DESCRIPTION:
  1461.     
  1462.           Returns TRUE (1) if the passed character 'c' is a printable  ASCII
  1463.        character which is not a letter of the alphabet or a  numeric  digit,
  1464.        otherwise FALSE (0) is returned.
  1465.     
  1466.     
  1467.     EXAMPLES:
  1468.     
  1469.         while(ispunct(*ptr))
  1470.             ++ptr;
  1471.     ISSPACE                                                         ISSPACE
  1472.     
  1473.     
  1474.     
  1475.     PROTOTYPE:
  1476.     
  1477.         int isspace(char c)
  1478.     
  1479.     
  1480.     ARGUMENTS:
  1481.     
  1482.         c       - Any character value
  1483.     
  1484.     
  1485.     RETURN VALUE:
  1486.     
  1487.         1 if 'c' is a space character (space, tab or newline)
  1488.         0 if 'c' is not a space character
  1489.     
  1490.     
  1491.     DESCRIPTION:
  1492.     
  1493.           Returns TRUE (1) if the passed character 'c' is one  of  a  space,
  1494.        tab or newline, otherwise FALSE (0) is returned.
  1495.     
  1496.     
  1497.     EXAMPLES:
  1498.     
  1499.         while(isspace(*ptr))
  1500.             ++ptr;
  1501.     ISUPPER                                                         ISUPPER
  1502.     
  1503.     
  1504.     
  1505.     PROTOTYPE:
  1506.     
  1507.         int isupper(char c)
  1508.     
  1509.     
  1510.     ARGUMENTS:
  1511.     
  1512.         c       - Any character value
  1513.     
  1514.     
  1515.     RETURN VALUE:
  1516.     
  1517.         1 if 'c' is upper case alphabetic
  1518.         0 if 'c' is not upper case alphabetic
  1519.     
  1520.     
  1521.     DESCRIPTION:
  1522.     
  1523.           Returns  TRUE  (1)  if  the  passed  character  'c'  is  an  ASCII
  1524.        alphabetic letter of upper case, otherwise FALSE (0) is returned.
  1525.     
  1526.     
  1527.     EXAMPLES:
  1528.     
  1529.         flag = isupper(input_char);
  1530.     ISXDIGIT                                                       ISXDIGIT
  1531.     
  1532.     
  1533.     
  1534.     PROTOTYPE:
  1535.     
  1536.         int isxdigit(char c)
  1537.     
  1538.     
  1539.     ARGUMENTS:
  1540.     
  1541.         c       - Any character value
  1542.     
  1543.     
  1544.     RETURN VALUE:
  1545.     
  1546.         1 if 'c' is a hexidecimal digit
  1547.         0 if 'c' is not a hexidecimal digit
  1548.     
  1549.     
  1550.     DESCRIPTION:
  1551.     
  1552.           Returns TRUE (1) is the passed character 'c'  is  an  valid  ASCII
  1553.        hexidecimal digit ('0'-'9', 'A'-'F', 'a'-'f'), otherwise FALSE (0) is
  1554.        returned.
  1555.     
  1556.     
  1557.     EXAMPLES:
  1558.     
  1559.         value = 0;
  1560.         while(isxdigit(*ptr))
  1561.             value = (value * 16) +
  1562.                 (isdigit(*ptr) ? *ptr++ - '0' : toupper(*ptr++) - ('A'-10));
  1563.     LGETC                                                             LGETC
  1564.     
  1565.     
  1566.     
  1567.     PROTOTYPE:
  1568.     
  1569.         int lgetc(HANDLE fh)
  1570.     
  1571.     
  1572.     ARGUMENTS:
  1573.     
  1574.         fh      - File handle for an input file
  1575.     
  1576.     
  1577.     RETURN VALUE:
  1578.     
  1579.         Value of a character read from the file (0-255)
  1580.         EOF (-1) if end of file or an error condition occurs
  1581.     
  1582.     
  1583.     DESCRIPTION:
  1584.     
  1585.           This function reads a single character from an  input  file  using
  1586.        LOW LEVEL (unbuffered) I/O, and returns it as a positive value in the
  1587.        range of 0 to 255. A full 16 bit value is returned, allowing the  end
  1588.        of file condition to be distinct from the character value 255.
  1589.     
  1590.     
  1591.     EXAMPLES:
  1592.     
  1593.         if((c = lgetc(input_file)) == EOF)
  1594.             abort("End of file encountered\n");
  1595.     LGETS                                                             LGETS
  1596.     
  1597.     
  1598.     
  1599.     PROTOTYPE:
  1600.     
  1601.         char *lgets(char *buffer, int size, HANDLE fh)
  1602.     
  1603.     
  1604.     ARGUMENTS:
  1605.     
  1606.         buffer  - Pointer to string to receive line
  1607.         size    - Maximum size of line to read
  1608.         fh      - File handle of an input file
  1609.     
  1610.     
  1611.     RETURN VALUE:
  1612.     
  1613.         Pointer to "buffer", or 0 if end of file
  1614.     
  1615.     
  1616.     DESCRIPTION:
  1617.     
  1618.           The "lgets" function reads characters  from  the  specified  input
  1619.        file using LOW  LEVEL  (unbuffered)  I/O,  and  places  them  in  the
  1620.        character buffer until one of three things happens:
  1621.     
  1622.           1) A NEWLINE character is encountered.
  1623.     
  1624.           2) The END of the file is encountered.
  1625.     
  1626.           3) The limit of "size" characters are read.
  1627.     
  1628.           The string is terminated with the standard  NULL  (00)  character.
  1629.        The trailing NEWLINE '\n' character is NOT  included  in  the  output
  1630.        buffer.
  1631.     
  1632.     
  1633.     EXAMPLES:
  1634.     
  1635.         lgets(input_line, 80, L_stdin);
  1636.     LONGJMP                                                         LONGJMP
  1637.     
  1638.     
  1639.     
  1640.     PROTOTYPE:
  1641.     
  1642.         longjmp(int savenv[3], int rvalue)
  1643.     
  1644.     
  1645.     ARGUMENTS:
  1646.     
  1647.         savenv  - Save area for program context
  1648.         rvalue  - Value to be returned by "setjmp"
  1649.     
  1650.     
  1651.     RETURN VALUE:
  1652.     
  1653.         N/A - Function never returns
  1654.     
  1655.     
  1656.     DESCRIPTION:
  1657.     
  1658.           The  "longjmp"  function  causes  execution  to  transfer  to  the
  1659.        "setjmp" call which  set  up  the  "savenv"  variable.  The  "setjmp"
  1660.        function will appear to return the value of "rvalue".
  1661.     
  1662.           NOTE-1: "longjmp" may  only  be  used  from  within  the  function
  1663.        calling "setjmp" or a function which has been called  "beneath"  that
  1664.        function. IT MUST NOT BE USED AFTER THE FUNCTION CALLING "SETJMP" HAS
  1665.        TERMINATED.
  1666.     
  1667.           NOTE-2: If "rvalue" is zero, the function  calling  "setjmp"  will
  1668.        assume that it is returning from initialization. Unless you want this
  1669.        unusual behavior, you should not pass  a  return  value  of  zero  to
  1670.        "longjmp".
  1671.     
  1672.           See also SETJMP.
  1673.     
  1674.     
  1675.     EXAMPLES:
  1676.     
  1677.         if(getc(stdin) == ('C'-'@'))    /* If Control-C entered... */
  1678.             longjmp(savearea, 1);       /* Return to main function */
  1679.     LONGMATH                                                       LONGMATH
  1680.     
  1681.     
  1682.     
  1683.     PROTOTYPES:
  1684.     
  1685.         int longadd(char *num1, char *num2);
  1686.         int longsub(char *num1, char *num2);
  1687.         longmul(char *num1, char *num2);
  1688.         longdiv(char *num1, char *num2);
  1689.         int longshr(char *num1);
  1690.         int longshl(char *num1);
  1691.         longcpy(char *num1, char *num2);
  1692.         longset(char *num1, unsigned value);
  1693.         int longtst(char *num1);
  1694.         int longcmp(char *num1, char *num2);
  1695.         extern char Longreg[];
  1696.     
  1697.     ARGUMENTS:
  1698.     
  1699.         num1    - First LONG operand, receives result if generated
  1700.         num2    - Second LONG operand, is not altered
  1701.         value   - 16 bit value to initialize LONG number with
  1702.     
  1703.     
  1704.     RETURN VALUE:
  1705.     
  1706.         longadd - 0 = Ok, 1 = addition overflowed
  1707.         longsub - 0 = Ok, 1 = subtraction underflowed
  1708.         longshr - Carry out of shift (1/0)
  1709.         longshl - Carry out of shift (1/0)
  1710.         longtst - 0 = Number is zero, !0 = Number is not zero
  1711.         longcmp - 0 = (num1 == num2), 1 = (num1 > num2), -1 = (num1 < num2)
  1712.     
  1713.     
  1714.     DESCRIPTION:
  1715.     
  1716.           This set of functions performs basic arithmetic functions on  LONG
  1717.        numbers:
  1718.     
  1719.         longadd(num1, num2)     ->  num1 += num2
  1720.         longsub(num1, num2)     ->  num1 -= num2
  1721.         longmul(num1, num2)     ->  num1 *= num2 , Longreg = num1 * num2
  1722.         longdiv(num1, num2)     ->  num1 /= num2 , Longreg = num1 % num2
  1723.         longshr(num1)           ->  num1 >>= 1
  1724.         longshl(num1)           ->  num1 <<= 1
  1725.         longcpy(num1, num2)     ->  num1 = num2
  1726.         longset(num1, value)    ->  num1 = (long) value
  1727.         longtst(num1)           ->  Test (num1 != 0)
  1728.         longcmp(num1, num2)     ->  Compare num1 and num2
  1729.     
  1730.           As shipped, a LONG number is 32 bits (4 bytes)  in  size,  however
  1731.        this can be changed by altering the LONGMATH.ASM in the library.
  1732.     
  1733.           For a complete example of using  these  functions,  refer  to  the
  1734.        LONGCALC.C example program included with the package.
  1735.     LPRINTF                                                         LPRINTF
  1736.     
  1737.     
  1738.     
  1739.     PROTOTYPE:
  1740.     
  1741.         register lprintf(int handle, char *format, arg, ...)
  1742.     
  1743.     
  1744.     ARGUMENTS:
  1745.     
  1746.         handle  - DOS file handle of output file
  1747.         format  - Pointer to format string
  1748.         arg     - Argument as determined by format string
  1749.         ...     - Additional arguments may be required
  1750.     
  1751.     
  1752.     RETURN VALUE:
  1753.     
  1754.         None
  1755.     
  1756.     
  1757.     DESCRIPTION:
  1758.     
  1759.           This routine performs a formatted print to  a  file  specified  by
  1760.        'fh', using LOW LEVEL (unbuffered) I/O.
  1761.     
  1762.           The 'format' string is written to  the  file  with  the  arguments
  1763.        substituted for special "conversion characters".  See  "fprintf"  for
  1764.        more information on format strings and conversions.
  1765.     
  1766.           NOTE: This function uses a variable number of arguments, and  must
  1767.        be declared as "register" (See "stdio.h").
  1768.     
  1769.     
  1770.     EXAMPLES:
  1771.     
  1772.         lprintf(fh, "Total errors=%u", error_count);
  1773.     LPUTC                                                             LPUTC
  1774.     
  1775.     
  1776.     
  1777.     PROTOTYPE:
  1778.     
  1779.         lputc(char c, HANDLE fh)
  1780.     
  1781.     
  1782.     ARGUMENTS:
  1783.     
  1784.         c       - Any character value
  1785.         fh      - File handle of an output file
  1786.     
  1787.     
  1788.     RETURN VALUE:
  1789.     
  1790.         0 if successful, otherwise an operating system error code
  1791.     
  1792.     
  1793.     DECRIPTION:
  1794.     
  1795.           This function writes the character 'c' to the  file  indicated  by
  1796.        'fh' using LOW LEVEL (unbuffered) I/O. The "newline"  (\n)  character
  1797.        will be translated into whatever character(s)  are  required  by  the
  1798.        operating system to separate records in the file.
  1799.     
  1800.     
  1801.     EXAMPLES:
  1802.     
  1803.         lputc('*', fh);
  1804.         lputc('\n', L_stderr);
  1805.     LPUTS                                                             LPUTS
  1806.     
  1807.     
  1808.     
  1809.     PROTOTYPE:
  1810.     
  1811.         lputs(char *string, HANDLE fh)
  1812.     
  1813.     
  1814.     ARGUMENTS:
  1815.     
  1816.         string  - Pointer to a character string
  1817.         fh      - File handle of an output file
  1818.     
  1819.     
  1820.     RETURN VALUE:
  1821.     
  1822.         0 if successful, otherwise an operating system error code
  1823.     
  1824.     
  1825.     DESCRIPTION:
  1826.     
  1827.           The "lputs" function writes the specified string to the  indicated
  1828.        output file using LOW LEVEL (unbuffered) I/O.  The  zero  terminating
  1829.        the string is NOT written.
  1830.     
  1831.     
  1832.     EXAMPLES:
  1833.     
  1834.         lputs("Text message", output_fh);
  1835.     LREWIND                                                         LREWIND
  1836.     
  1837.     
  1838.     
  1839.     PROTOTYPE:
  1840.     
  1841.         int lrewind(HANDLE fh)
  1842.     
  1843.     
  1844.     ARGUMENTS:
  1845.     
  1846.         fh      - File handle of an open file
  1847.     
  1848.     
  1849.     RETURN VALUE:
  1850.     
  1851.         0 if successful, otherwise an operating system error code
  1852.     
  1853.     
  1854.     DESCRIPTION:
  1855.     
  1856.           This function resets the operating system internal file handle  so
  1857.        than any subsequent read or writes will be at the  beginning  of  the
  1858.        file. For use with LOW LEVEL (unbuffered) file I/O only.
  1859.     
  1860.     
  1861.     EXAMPLES:
  1862.     
  1863.         lrewind(input_fh);
  1864.     LSCANF                                                           LSCANF
  1865.     
  1866.     
  1867.     
  1868.     PROTOTYPE:
  1869.     
  1870.         register int lscanf(int fh, char *format, &arg, ...)
  1871.     
  1872.     
  1873.     ARGUMENTS:
  1874.     
  1875.         fh      - DOS file handle of input file
  1876.         format  - Pointer to format string
  1877.         arg     - Argument as determined by format string
  1878.         ...     - Additional arguments may be required
  1879.     
  1880.     
  1881.     RETURN VALUE:
  1882.     
  1883.         The number of successful matches
  1884.         EOF (-1) if end of file or an error condition occurs
  1885.     
  1886.     
  1887.     DESCRIPTION:
  1888.     
  1889.           This routine reads a line from the specified file using LOW  LEVEL
  1890.        (unbuffered) I/O, and scans it for specific  values  which  are  then
  1891.        assigned to the  passed  argument  addresses.  The  types  of  values
  1892.        scanned are determined by special "conversion characters" within  the
  1893.        "format" string.
  1894.     
  1895.           See "fscanf" for more information on format strings.
  1896.     
  1897.           NOTE: This function uses a variable number of arguments, and  must
  1898.        be declared as "register".
  1899.     
  1900.     
  1901.     EXAMPLES:
  1902.     
  1903.         if(lscanf(infile,"%s %s %u", first_name, last_name, &age) != 3)
  1904.             abort("Error in user record\n");
  1905.     LSEEK                                                             LSEEK
  1906.     
  1907.     
  1908.     
  1909.     PROTOTYPE:
  1910.     
  1911.         (1) int lseek(HANDLE fh, int h_offset, unsigned l_offset, int mode)
  1912.         (2) int lseek(HANDLE fh, int offset, mode)
  1913.     
  1914.     
  1915.     ARGUMENTS:
  1916.     
  1917.         fh  - File handle of an open file
  1918.         h_offset- Highest 16 bits of offset value
  1919.         l_offset- Lowest 16 bits of offset value
  1920.         offset  - 16 bit offset value
  1921.         mode    - Type of seek
  1922.                     0 = Absolute from start of file
  1923.                     1 = Signed offset from current position
  1924.                     2 = Signed offset from end of file
  1925.     
  1926.     
  1927.     RETURN VALUE:
  1928.     
  1929.         0 if successful, otherwise an operating system error code
  1930.     
  1931.     
  1932.     DESCRIPTION:
  1933.     
  1934.           This function positions the operating system internal pointer into
  1935.        a file so that any read or write will take  place  at  the  specified
  1936.        position in the file.
  1937.     
  1938.           Most operating systems which support files of > 64K bytes in  size
  1939.        will support form (1) of the function, using both high and low offset
  1940.        values.
  1941.     
  1942.           Smaller operating  systems  may  only  support  form  (2)  of  the
  1943.        function, allowing seeking of only +/- 32K bytes.
  1944.     
  1945.           Also, some implementations may not support  all  "modes",  or  may
  1946.        only allow unsigned (positive) offsets.
  1947.     
  1948.           For use with LOW LEVEL (unbuffered I/O only).
  1949.     
  1950.     
  1951.     EXAMPLES:
  1952.     
  1953.         lseek(input_fh, 0, 2);  /* Advance to end of file */
  1954.     LTELL                                                             LTELL
  1955.     
  1956.     
  1957.     
  1958.     PROTOTYPE:
  1959.     
  1960.         (1) int ltell(HANDLE fh, int &h_offset, unsigned &l_offset)
  1961.         (2) int ltell(HANDLE fh, int &offset)
  1962.     
  1963.     
  1964.     ARGUMENTS:
  1965.     
  1966.         fh      - File handle of an open file
  1967.         h_offset- Address of int to receive high word of offset
  1968.         l_offset- Address of int to receive low word of offset
  1969.         offset  - Address of int to receive offset
  1970.     
  1971.     
  1972.     RETURN VALUE:
  1973.     
  1974.         0 if successful, otherwise an operating system error code
  1975.     
  1976.     
  1977.     DESCRIPTION:
  1978.     
  1979.           This function gets the current read/write position within a  file.
  1980.        The position returned indicates the absolute character (byte)  offset
  1981.        from the start of the file where the next read  or  write  will  take
  1982.        place.
  1983.     
  1984.           Most operating systems which support files of > 64K bytes in  size
  1985.        will support form (1) of the function, returning both  high  and  low
  1986.        offset values.
  1987.     
  1988.           Smaller operating  systems  may  only  support  form  (2)  of  the
  1989.        function,  allowing  access  to  only  the  first   65535   character
  1990.        positions.
  1991.     
  1992.           For use with LOW LEVEL (unbuffered I/O only).
  1993.     
  1994.     
  1995.     EXAMPLES:
  1996.     
  1997.         ltell(fp, &oldh, &oldl);    /* Save file position */
  1998.             . . .                   /* Perform some operations on the file */
  1999.         lseek(fp, oldh, oldl, 0);   /* Return to previous position */
  2000.     MALLOC                                                           MALLOC
  2001.     
  2002.     
  2003.     
  2004.     PROTOTYPE:
  2005.     
  2006.         char *malloc(int size)
  2007.     
  2008.     
  2009.     ARGUMENTS:
  2010.     
  2011.         size    - Size of memory block to allocate (in bytes).
  2012.     
  2013.     
  2014.     RETURN VALUE:
  2015.     
  2016.         0       - Memory allocation failed
  2017.         !0      - Pointer to allocated memory block
  2018.     
  2019.     
  2020.     DESCRIPTION:
  2021.     
  2022.           The "malloc" function allocates a block of memory of the specified
  2023.        size from the heap, and returns a pointer to  it.  This  memory  will
  2024.        remain allocated until it is  explicitly  released  with  the  "free"
  2025.        function.
  2026.     
  2027.     
  2028.     EXAMPLES:
  2029.     
  2030.         if(!(ptr = malloc(BUFSIZ)))     /* Allocate a temporary buffer */
  2031.             abort("Not enough memory");
  2032.         do {                            /* Copy the file over */
  2033.             size = fread(ptr, BUFSIZ, in_fp);
  2034.             fwrite(ptr, size, out_fp); }
  2035.         while(size == BUFSIZ);
  2036.         free(ptr);                      /* Release temporary buffer */
  2037.     MAX                                                                 MAX
  2038.     
  2039.     
  2040.     
  2041.     PROTOTYPE:
  2042.     
  2043.         int max(int value1, int value2)
  2044.     
  2045.     
  2046.     ARGUMENTS:
  2047.     
  2048.         value1  - Any integer value
  2049.         value2  - Any integer value
  2050.     
  2051.     
  2052.     RETURN VALUE:
  2053.     
  2054.         The greater of "value1" or "value2"
  2055.     
  2056.     
  2057.     DESCRIPTION:
  2058.     
  2059.           The "max" function returns the higher of its two argument values.
  2060.     
  2061.     
  2062.     EXAMPLES:
  2063.     
  2064.         biggest = max(a, b);
  2065.     MEMCPY                                                           MEMCPY
  2066.     
  2067.     
  2068.     
  2069.     PROTOTYPE:
  2070.     
  2071.         memcpy(char *dest, char *source, unsigned size)
  2072.     
  2073.     
  2074.     ARGUMENTS:
  2075.     
  2076.         dest    - Pointer to the destination
  2077.         source  - Pointer to the souce
  2078.         size    - Number of bytes to copy
  2079.     
  2080.     
  2081.     RETURN VALUE:
  2082.     
  2083.         None
  2084.     
  2085.     
  2086.     DESCRIPTION:
  2087.     
  2088.           The "memcpy" function will copy the specified number of bytes from
  2089.        the source to the destination. If the source and  destination  blocks
  2090.        overlap, the function may not copy the entire block correctly.
  2091.     
  2092.     
  2093.     EXAMPLES:
  2094.     
  2095.         memcpy(buffer1, buffer2, 256);
  2096.     MEMMOVE                                                         MEMMOVE
  2097.     
  2098.     
  2099.     
  2100.     PROTOTYPE:
  2101.     
  2102.         memmove(char *dest, char *source, unsigned size)
  2103.     
  2104.     
  2105.     ARGUMENTS:
  2106.     
  2107.         dest    - Pointer to the destination
  2108.         source  - Pointer to the souce
  2109.         size    - Number of bytes to copy
  2110.     
  2111.     
  2112.     RETURN VALUE:
  2113.     
  2114.         None
  2115.     
  2116.     
  2117.     DESCRIPTION:
  2118.     
  2119.           This function is similar to "memcpy", with the exception  that  it
  2120.        will copy overlapping blocks  of  memory  correctly.  It  is  however
  2121.        slightly larger than memcpy().
  2122.     
  2123.     
  2124.     EXAMPLES:
  2125.     
  2126.         memmove(buffer1, buffer2, 256);
  2127.     MEMSET                                                           MEMSET
  2128.     
  2129.     
  2130.     
  2131.     PROTOTYPE:
  2132.     
  2133.         memset(char *block, char value, unsigned size)
  2134.     
  2135.     
  2136.     ARGUMENTS:
  2137.     
  2138.         block   - Pointer to a block of memory
  2139.         value   - Value to initialize memory with
  2140.         size    - Number of bytes to initialize
  2141.     
  2142.     
  2143.     RETURN VALUE:
  2144.     
  2145.         None
  2146.     
  2147.     
  2148.     DESCRIPTION:
  2149.     
  2150.           Sets a block of memory  beginning  at  the  pointer  "block",  for
  2151.        "size" bytes to the byte value "value".
  2152.     
  2153.     
  2154.     EXAMPLES:
  2155.     
  2156.         memset(buffer, 0, 100);
  2157.     MIN                                                                 MIN
  2158.     
  2159.     
  2160.     
  2161.     PROTOTYPE:
  2162.     
  2163.         int min(int value1, int value2)
  2164.     
  2165.     
  2166.     ARGUMENTS:
  2167.     
  2168.         value1  - Any integer value
  2169.         value2  - Any integer value
  2170.     
  2171.     
  2172.     RETURN VALUE:
  2173.     
  2174.         The smaller of "value1" or "value2"
  2175.     
  2176.     
  2177.     DESCRIPTION:
  2178.     
  2179.           The "min" function returns the lower of its two argument values.
  2180.     
  2181.     
  2182.     EXAMPLES:
  2183.     
  2184.         least = min(a, b);
  2185.     MKDIR                                                             MKDIR
  2186.     
  2187.     
  2188.     
  2189.     PROTOTYPE:
  2190.     
  2191.         int mkdir(char *pathname)
  2192.     
  2193.     
  2194.     ARGUMENTS:
  2195.     
  2196.         pathname- Name of directory to create
  2197.     
  2198.     
  2199.     RETURN VALUE:
  2200.     
  2201.         0 if successful, otherwise an operating system error code
  2202.     
  2203.     
  2204.     DESCRIPTION:
  2205.     
  2206.           The "mkdir" function create a new directory on the disk under  the
  2207.        specified path name.
  2208.     
  2209.     
  2210.     EXAMPLES:
  2211.     
  2212.         mkdir("subdir");
  2213.     NARGS                                                             NARGS
  2214.     
  2215.     
  2216.     
  2217.     PROTOTYPE:
  2218.     
  2219.         int nargs()
  2220.     
  2221.     
  2222.     ARGUMENTS:
  2223.     
  2224.         None
  2225.     
  2226.     
  2227.     RETURN VALUE:
  2228.     
  2229.         The number of arguments passed to the calling function
  2230.     
  2231.     
  2232.     DESCRIPTION:
  2233.     
  2234.           Returns the number of arguments passed to a "register" function.
  2235.     
  2236.           NOTE: When  calling  a  "register"  function,  MICRO-C  loads  the
  2237.        accumulator with the number of arguments just prior  to  calling  the
  2238.        function. This "nargs" routine is  simply  a  null  definition  which
  2239.        returns with the same value in the accumulator as was there  when  it
  2240.        was called. Therefore "nargs" MUST BE  THE  FIRST  ARITHMETIC  ENTITY
  2241.        EVALUATED WITHIN  THE  REGISTER  FUNCTION  or  the  contents  of  the
  2242.        accumulator will be lost. Some examples of "register" definitions and
  2243.        the use of "nargs" may be found in the library source code.
  2244.     
  2245.     
  2246.     EXAMPLES:
  2247.     
  2248.         first_arg = nargs() * 2 + &arguments;
  2249.     OPEN                                                               OPEN
  2250.     
  2251.     
  2252.     
  2253.     PROTOTYPE:
  2254.     
  2255.         HANDLE open(char *filename, int options)
  2256.     
  2257.     
  2258.     ARGUMENTS:
  2259.     
  2260.         filename- Name of the file to open
  2261.         options - Open options (defined in file.h)
  2262.     
  2263.     
  2264.     RETURN VALUE:
  2265.     
  2266.         File handle for the open file
  2267.         Zero (0) if file could not be opened
  2268.     
  2269.     
  2270.     DESCRIPTION:
  2271.     
  2272.           This function  open  a  file  for  direct  access  via  LOW  LEVEL
  2273.        (unbuffered) I/O.
  2274.     
  2275.     
  2276.     EXAMPLES:
  2277.     
  2278.         if(fh = open("data.img", F_READ)) {
  2279.             read(data_buf, 100, fh);
  2280.             close(fh); }
  2281.         else
  2282.             abort("Unable to read data file");
  2283.     OUT                                                                 OUT
  2284.     
  2285.     
  2286.     
  2287.     PROTOTYPE:
  2288.     
  2289.         out(unsigned port, int value)
  2290.     
  2291.     
  2292.     ARGUMENTS:
  2293.     
  2294.         port    - I/O port address
  2295.         value   - Value to write to I/O port
  2296.     
  2297.     
  2298.     RETURN VALUE:
  2299.     
  2300.         None
  2301.     
  2302.     
  2303.     DESCRIPTION:
  2304.     
  2305.           The "out" function writes a byte (8 bit) value to an I/O port.
  2306.     
  2307.           The valid range of values for "port" depends on  the  I/O  address
  2308.        space of the processor.
  2309.     
  2310.           This function is not provided for processors which do not  support
  2311.        a separate I/O address space.
  2312.     
  2313.     
  2314.     EXAMPLES:
  2315.     
  2316.         out(0, 0);      /* Output 0 to I/O port 0 */
  2317.     OUTW                                                               OUTW
  2318.     
  2319.     
  2320.     
  2321.     PROTOTYPE:
  2322.     
  2323.         outw(unsigned port, int value)
  2324.     
  2325.     
  2326.     ARGUMENTS:
  2327.     
  2328.         port    - I/O port address
  2329.         value   - Value to write to I/O port
  2330.     
  2331.     
  2332.     RETURN VALUE:
  2333.     
  2334.         None
  2335.     
  2336.     
  2337.     DESCRIPTION:
  2338.     
  2339.           The "outw" function writes a word (16 bit) value to an I/O port.
  2340.     
  2341.           The valid range of values for "port" depends on  the  I/O  address
  2342.        space of the processor.
  2343.     
  2344.           This function is not provided for processors which do not  support
  2345.        a separate I/O address space.
  2346.     
  2347.     
  2348.     EXAMPLES:
  2349.     
  2350.         outw(0, 0);     /* Write 0 to I/O ports 0 and 1 */
  2351.     PEEK                                                               PEEK
  2352.     
  2353.     
  2354.     
  2355.     PROTOTYPE:
  2356.     
  2357.         (1) int peek(unsigned address)
  2358.         (2) int peek(unsigned h_addr, unsigned l_addr)
  2359.         (3) int peek(unsigned segment, unsigned offset)
  2360.     
  2361.     
  2362.     ARGUMENTS:
  2363.     
  2364.         segment - Memory segment
  2365.         offset  - Offset into segment
  2366.         h_addr  - High word of memory address
  2367.         l_addr  - Low word of memory address
  2368.         address - 16 bit memory address
  2369.     
  2370.     
  2371.     RETURN VALUE:
  2372.     
  2373.         The 8 bit value read from the given memory address
  2374.     
  2375.     
  2376.     DESCRIPTION:
  2377.     
  2378.           The "peek" function reads and returns a byte (8 bits) from  memory
  2379.        as an integer value between 0 and 255.
  2380.     
  2381.           Processors such as the 8080 or 6809 which address 64K of memory or
  2382.        less use form (1) of the function.
  2383.     
  2384.           Non-segmented processors addressing more  than  64K  such  as  the
  2385.        68000 use form (2) of the function.
  2386.     
  2387.           Processors employing a "segmented" architecture such as  the  8086
  2388.        use form (3) of the function.
  2389.     
  2390.     
  2391.     EXAMPLES:
  2392.     
  2393.         while(peek(0)); /* Wait for flag to clear */
  2394.     PEEKW                                                             PEEKW
  2395.     
  2396.     
  2397.     
  2398.     PROTOTYPE:
  2399.     
  2400.         (1) int peekw(unsigned address)
  2401.         (2) int peekw(unsigned h_addr, unsigned l_addr)
  2402.         (3) int peekw(unsigned segment, unsigned offset)
  2403.     
  2404.     
  2405.     ARGUMENTS:
  2406.     
  2407.         segment - Memory segment
  2408.         offset  - Offset into segment
  2409.         h_addr  - High word of memory address
  2410.         l_addr  - Low word of memory address
  2411.         address - 16 bit memory address
  2412.     
  2413.     
  2414.     RETURN VALUE:
  2415.     
  2416.         The 16 bit value read from the given memory address
  2417.     
  2418.     
  2419.     DESCRIPTION:
  2420.     
  2421.           The "peekw" function reads and  returns  a  word  (16  bits)  from
  2422.        memory as an integer value between 0 and 65535 (-1).
  2423.     
  2424.           Processors such as the 8080 or 6809 which address 64K of memory or
  2425.        less use form (1) of the function.
  2426.     
  2427.           Non-segmented processors addressing more  than  64K  such  as  the
  2428.        68000 use form (2) of the function.
  2429.     
  2430.           Processors employing a "segmented" architecture such as  the  8086
  2431.        use form (3) of the function.
  2432.     
  2433.     
  2434.     EXAMPLES:
  2435.     
  2436.         var = peekw(0));
  2437.     POKE                                                               POKE
  2438.     
  2439.     
  2440.     
  2441.     PROTOTYPE:
  2442.     
  2443.         (1) poke(unsigned address, int value)
  2444.         (2) poke(unsigned h_addr, unsigned l_addr, int value)
  2445.         (3) poke(unsigned segment, unsigned offset, int value)
  2446.     
  2447.     
  2448.     ARGUMENTS:
  2449.     
  2450.         segment - Memory segment
  2451.         offset  - Offset into segment
  2452.         h_addr  - High word of memory address
  2453.         l_addr  - Low word of memory address
  2454.         address - 16 bit memory address
  2455.         value   - Value to be written to memory
  2456.     
  2457.     
  2458.     RETURN VALUE:
  2459.     
  2460.         None
  2461.     
  2462.     
  2463.     DESCRIPTION:
  2464.     
  2465.           The "poke" function writes a byte (8 bit) value to memory.
  2466.     
  2467.           Processors such as the 8080 or 6809 which address 64K of memory or
  2468.        less use form (1) of the function.
  2469.     
  2470.           Non-segmented processors addressing more  than  64K  such  as  the
  2471.        68000 use form (2) of the function.
  2472.     
  2473.           Processors employing a "segmented" architecture such as  the  8086
  2474.        use form (3) of the function.
  2475.     
  2476.     
  2477.     EXAMPLES:
  2478.     
  2479.         poke(0, 0);     /* Write 0 to location 0 */
  2480.     POKEW                                                             POKEW
  2481.     
  2482.     
  2483.     
  2484.     PROTOTYPE:
  2485.     
  2486.         (1) pokew(unsigned address, int value)
  2487.         (2) pokew(unsigned h_addr, unsigned l_addr, int value)
  2488.         (3) pokew(unsigned segment, unsigned offset, int value)
  2489.     
  2490.     
  2491.     ARGUMENTS:
  2492.     
  2493.         segment - Memory segment
  2494.         offset  - Offset into segment
  2495.         h_addr  - High word of memory address
  2496.         l_addr  - Low word of memory address
  2497.         address - 16 bit memory address
  2498.         value   - Value to be written to memory
  2499.     
  2500.     
  2501.     RETURN VALUE:
  2502.     
  2503.         None
  2504.     
  2505.     
  2506.     DESCRIPTION:
  2507.     
  2508.           The "pokew" function writes a word (16 bit) value to memory.
  2509.     
  2510.           Processors such as the 8080 or 6809 which address 64K of memory or
  2511.        less use form (1) of the function.
  2512.     
  2513.           Non-segmented processors addressing more  than  64K  such  as  the
  2514.        68000 use form (2) of the function.
  2515.     
  2516.           Processors employing a "segmented" architecture such as  the  8086
  2517.        use form (3) of the function.
  2518.     
  2519.     
  2520.     EXAMPLES:
  2521.     
  2522.         pokew(0, 0);    /* Write 0 to locations 0 and 1 */
  2523.     PRINTF                                                           PRINTF
  2524.     
  2525.     
  2526.     
  2527.     PROTOTYPE:
  2528.     
  2529.         register printf(char *format, arg, ...)
  2530.     
  2531.     
  2532.     ARGUMENTS:
  2533.     
  2534.         format  - Pointer to format string
  2535.         arg     - Argument as determined by format string
  2536.         ...     - Additional arguments may be required
  2537.     
  2538.     
  2539.     RETURN VALUE:
  2540.     
  2541.         None
  2542.     
  2543.     
  2544.     DESCRIPTION:
  2545.     
  2546.           The "printf" routine performs a formatted print  to  the  standard
  2547.        output device  (usually  system  console).  The  "format"  string  is
  2548.        written  with  the  arguments  substituted  for  special  "conversion
  2549.        characters".
  2550.     
  2551.           See "fprintf" for more information on format strings.
  2552.     
  2553.           NOTE: This function uses a variable number of arguments, and  must
  2554.        be declared as "register" (See "stdio.h").
  2555.     
  2556.     
  2557.     EXAMPLES:
  2558.     
  2559.         printf("Hello world!!!\n");
  2560.         printf("File '%s', has %u lines\n", filename, num_lines);
  2561.     PUTC                                                               PUTC
  2562.     
  2563.     
  2564.     
  2565.     PROTOTYPE:
  2566.     
  2567.         putc(char c, FILE *fp)
  2568.     
  2569.     
  2570.     ARGUMENTS:
  2571.     
  2572.         c       - Any character value
  2573.         fp      - File pointer to an output file
  2574.     
  2575.     
  2576.     RETURN VALUE:
  2577.     
  2578.         0 if successful, otherwise an operating system error code
  2579.     
  2580.     
  2581.     DECRIPTION:
  2582.     
  2583.           This function writes the character 'c' to the  file  indicated  by
  2584.        the file pointer 'fp'.
  2585.     
  2586.     
  2587.     EXAMPLES:
  2588.     
  2589.         putc('*', fp);
  2590.         putc('\n', stderr);
  2591.     RAND                                                               RAND
  2592.     
  2593.     
  2594.     
  2595.     PROTOTYPE:
  2596.     
  2597.         unsigned rand(unsigned limit)
  2598.     
  2599.     
  2600.     ARGUMENTS:
  2601.     
  2602.         limit   - Maximum value to return
  2603.     
  2604.     
  2605.     RETURN VALUE:
  2606.     
  2607.         A pseudo-random number in the range of 0 to (limit-1)
  2608.     
  2609.     
  2610.     DESCRIPTION:
  2611.     
  2612.           The "rand" function calculates the next value of  a  pseudo-random
  2613.        sequence, based on a 16 bit unsigned "seed" value, which it maintains
  2614.        in the global variable "RAND_SEED". The new value is  stored  as  the
  2615.        new seed value, and is then divided  by  the  "limit"  parameter,  to
  2616.        obtain the remainder, which is returned. This  results  in  a  random
  2617.        number in the range of zero (0) to (limit - 1).
  2618.     
  2619.           Any  particular  sequence  may  be  repeated,  by   reseting   the
  2620.        "RAND_SEED" value.
  2621.     
  2622.     
  2623.     EXAMPLES:
  2624.     
  2625.         value = rand(52);
  2626.     READ                                                               READ
  2627.     
  2628.     
  2629.     
  2630.     PROTOTYPE:
  2631.     
  2632.         int read(char *buffer, int size, HANDLE fh)
  2633.     
  2634.     
  2635.     ARGUMENTS:
  2636.     
  2637.         buffer  - Pointer to buffer to receive data
  2638.         size    - Number of bytes to read
  2639.         fh      - File handle of an input file
  2640.     
  2641.     
  2642.     RETURN VALUE:
  2643.     
  2644.         Number of bytes read from file
  2645.     
  2646.     
  2647.     DESCRIPTION:
  2648.     
  2649.           This function reads a block of data from a file  using  LOW  LEVEL
  2650.        (unbuffered) I/O, and places it in memory at the address of "buffer".
  2651.        Data is read in "raw"  form,  with  no  interpretation  of  "newline"
  2652.        characters etc. If the number of bytes  returned  is  less  than  the
  2653.        number of bytes requested, either the end of the file was encountered
  2654.        or an error condition occured (in which case the value will be zero).
  2655.     
  2656.     
  2657.     EXAMPLES:
  2658.     
  2659.         read(block, 512, input_fh);
  2660.     RENAME                                                           RENAME
  2661.     
  2662.     
  2663.     
  2664.     PROTOTYPE:
  2665.     
  2666.         int rename(char *pathname, char *newname)
  2667.     
  2668.     
  2669.     ARGUMENTS:
  2670.     
  2671.         pathname- Name of file to rename
  2672.         newname - New name for file
  2673.     
  2674.     
  2675.     RETURN VALUE:
  2676.     
  2677.         0 if successful, otherwise an operating system error code
  2678.     
  2679.     
  2680.     DESCRIPTION:
  2681.     
  2682.           This function changes the name of an existing file  to  the  ASCII
  2683.        string specified by newname.
  2684.     
  2685.     
  2686.     EXAMPLES:
  2687.     
  2688.         rename("output.dat", "output.bak");
  2689.     REWIND                                                           REWIND
  2690.     
  2691.     
  2692.     
  2693.     PROTOTYPE:
  2694.     
  2695.         int rewind(FILE *fp)
  2696.     
  2697.     
  2698.     ARGUMENTS:
  2699.     
  2700.         fp      - File pointer to an open file
  2701.     
  2702.     
  2703.     RETURN VALUE:
  2704.     
  2705.         0 if successful, otherwise an operating system error code
  2706.     
  2707.     
  2708.     DESCRIPTION:
  2709.     
  2710.           This function resets the operating system internal file pointer so
  2711.        than any subsequent read or writes will be at the  beginning  of  the
  2712.        file.
  2713.     
  2714.     
  2715.     EXAMPLES:
  2716.     
  2717.         rewind(input_file);
  2718.     RMDIR                                                             RMDIR
  2719.     
  2720.     
  2721.     
  2722.     PROTOTYPE:
  2723.     
  2724.         int rmdir(char *pathname)
  2725.     
  2726.     
  2727.     ARGUMENTS:
  2728.     
  2729.         pathname- Name of directory to delete
  2730.     
  2731.     
  2732.     RETURN VALUE:
  2733.     
  2734.         0 if successful, otherwise an operating system error code
  2735.     
  2736.     
  2737.     DESCRIPTION:
  2738.     
  2739.           This function removes a directory from the disk. On most  systems,
  2740.        the directory  must  be  empty  (contains  no  files)  otherwise  the
  2741.        function will fail.
  2742.     
  2743.     
  2744.     EXAMPLES:
  2745.     
  2746.         rmdir("subdir");
  2747.     SCANF                                                             SCANF
  2748.     
  2749.     
  2750.     
  2751.     PROTOTYPE:
  2752.     
  2753.         register int scanf(char *format, arg1, arg2, ...)
  2754.     
  2755.     
  2756.     ARGUMENTS:
  2757.     
  2758.         format  - Pointer to format string
  2759.         arg     - Argument as determined by format string
  2760.         ...     - Additional arguments may be required
  2761.     
  2762.     
  2763.     RETURN VALUE:
  2764.     
  2765.         The number of successful matches
  2766.         EOF (-1) if end of file or an error condition occurs
  2767.     
  2768.     
  2769.     DESCRIPTION:
  2770.     
  2771.           The "scanf" function reads and scans  a  line  from  the  standard
  2772.        input device (usually system console) for specific values. Values are
  2773.        read and assigned to  the  passed  argument  addresses  according  to
  2774.        special "conversion characters" in the "format" string.
  2775.     
  2776.           See "fscanf" for more information on format strings.
  2777.     
  2778.           NOTE: This function uses a variable number of arguments, and  must
  2779.        be declared as "register".
  2780.     
  2781.     
  2782.     EXAMPLES:
  2783.     
  2784.         do
  2785.             printf("Please enter your First & Last names, and your age?");
  2786.         while(scanf("%s %s %u", first_name, last_name, &age) != 3);
  2787.     SETBUF                                                           SETBUF
  2788.     
  2789.     
  2790.     
  2791.     PROTOTYPE:
  2792.     
  2793.         FILE *setbuf(FILE *fp, int size)
  2794.     
  2795.     
  2796.     ARGUMENTS:
  2797.     
  2798.         fp      - File pointer to an open file
  2799.         size    - Size of new I/O buffer
  2800.     
  2801.     
  2802.     RETURN VALUE:
  2803.     
  2804.         If successful, a new file pointer is returned, and the old one
  2805.         is released. On failure the old file pointer is returned.
  2806.     
  2807.     
  2808.     DESCRIPTION:
  2809.     
  2810.           The "setbuf" function will adjust the size of the buffer used  for
  2811.        I/O operations on the indicated open file.
  2812.     
  2813.           This is the ONLY way to set the buffer size for  the  "stdin"  and
  2814.        "stdout" streams. If you change the size of the "stdout" buffer,  you
  2815.        must remember to "fflush(stdout)" before terminating,  otherwise  the
  2816.        last buffer contents may not be written.
  2817.     
  2818.           For file opened by "fopen",  the  buffer  size  may  be  set  more
  2819.        efficently by setting the value of the external  variable  "IOB_size"
  2820.        prior to calling "fopen".
  2821.     
  2822.           If "setbuf" is unable to allocate space for  the  new  buffer,  it
  2823.        will return the old file pointer unchanged.
  2824.     
  2825.     
  2826.     EXAMPLES:
  2827.     
  2828.         stdout = setbuf(stdout, 512);   /* Set stdout to 512 byte buffer */
  2829.     SETJMP                                                           SETJMP
  2830.     
  2831.     
  2832.     
  2833.     PROTOTYPE:
  2834.     
  2835.         int setjmp(int savenv[3])
  2836.     
  2837.     
  2838.     ARGUMENTS:
  2839.     
  2840.         savenv  - Save area for program context
  2841.     
  2842.     
  2843.     RETURN VALUE:
  2844.     
  2845.         0 is returned when actually called
  2846.         Value passed to "longjmp" is returned otherwise
  2847.     
  2848.     
  2849.     DESCRIPTION:
  2850.     
  2851.           When called, the "setjmp" function stores  the  current  execution
  2852.        state of the program into the passed integer array, and  returns  the
  2853.        value zero.
  2854.     
  2855.           The "longjmp" function may then be used to return the  program  to
  2856.        the "setjmp" call. In this case, the value returned by "setjmp"  will
  2857.        be the value which was passed to "longjmp". This allows the  function
  2858.        containing "setjmp" to determine which call to  "longjmp"  transfered
  2859.        execution to it.
  2860.     
  2861.           See also LONGJMP.
  2862.     
  2863.     
  2864.     EXAMPLES:
  2865.     
  2866.         switch(setjmp(savearea)) {
  2867.             case 0 : printf("Longjmp has been set up"); break;
  2868.             case 1 : printf("Control-C Interrupt");     break;
  2869.             case 2 : printf("Reset command executed");  break;
  2870.             default: printf("Software error trap");     break; }
  2871.     SPRINTF                                                         SPRINTF
  2872.     
  2873.     
  2874.     
  2875.     PROTOTYPE:
  2876.     
  2877.         register sprintf(char *dest, char *format, arg, ...)
  2878.     
  2879.     
  2880.     ARGUMENTS:
  2881.     
  2882.         dest    - Pointer to destination string
  2883.         format  - Pointer to format string
  2884.         arg     - Argument as determined by format string
  2885.         ...     - Additional arguments may be required
  2886.     
  2887.     
  2888.     RETURN VALUE:
  2889.     
  2890.         None
  2891.     
  2892.     
  2893.     DESCRIPTION:
  2894.     
  2895.           The "sprintf" routine performs a formatted print to  a  string  in
  2896.        memory. The "format" string is written to the destination string with
  2897.        the arguments substituted for special "conversion characters".
  2898.     
  2899.           See "fprintf" for more information on format strings.
  2900.     
  2901.           NOTE: This function uses a variable number of arguments, and  must
  2902.        be declared as "register" (See "stdio.h").
  2903.     
  2904.     
  2905.     EXAMPLES:
  2906.     
  2907.         sprintf(header_file, "/lib/%s.h", header_name);
  2908.     SQRT                                                               SQRT
  2909.     
  2910.     
  2911.     
  2912.     PROTOTYPE:
  2913.     
  2914.         int sqrt(unsigned value)
  2915.     
  2916.     
  2917.     ARGUMENTS:
  2918.     
  2919.         value   - Number for which to calculate square root
  2920.     
  2921.     
  2922.     RETURN VALUE:
  2923.     
  2924.         The integer square root (rounded up) of the argument value
  2925.     
  2926.     
  2927.     DESCRIPTION:
  2928.     
  2929.           The  SQRT  function  returns  the  smallest  number   which   when
  2930.        multiplied by itself will give a number equal to or larger  that  the
  2931.        argument value.
  2932.     
  2933.     
  2934.     EXAMPLES:
  2935.     
  2936.     /*
  2937.      * Draw a circle about point (x, y) of radus (r)
  2938.      */
  2939.     circle(x, y, r)
  2940.         int x, y, r;
  2941.     {
  2942.         int i, j, k, rs, lj;
  2943.     
  2944.         rs = (lj = r)*r;
  2945.         for(i=0; i <= r; ++i) {
  2946.             j = k = sqrt(rs - (i*i));
  2947.             do {
  2948.                 plot_xy(x+i, y+j);
  2949.                 plot_xy(x+i, y-j);
  2950.                 plot_xy(x-i, y+j);
  2951.                 plot_xy(x-i, y-j); }
  2952.             while(++j < lj);
  2953.             lj = k; }
  2954.     }
  2955.     SSCANF                                                           SSCANF
  2956.     
  2957.     
  2958.     
  2959.     PROTOTYPE:
  2960.     
  2961.         register int sscanf(char *input, char *format, arg1, arg2, ...)
  2962.     
  2963.     
  2964.     ARGUMENTS:
  2965.     
  2966.         input   - Pointer to input string
  2967.         format  - Pointer to format string
  2968.         arg     - Argument as determined by format string
  2969.         ...     - Additional arguments may be required
  2970.     
  2971.     
  2972.     RETURN VALUE:
  2973.     
  2974.         The number of successful matches
  2975.     
  2976.     
  2977.     DESCRIPTION:
  2978.     
  2979.           The "sscanf" function  scans  a  string  in  memory  for  specific
  2980.        values. Values are read and assigned to the passed argument addresses
  2981.        according to special "conversion characters" in the "format" string.
  2982.     
  2983.           See "fscanf" for more information on format strings.
  2984.     
  2985.           NOTE: This function uses a variable number of arguments, and  must
  2986.        be declared as "register".
  2987.     
  2988.     
  2989.     EXAMPLES:
  2990.     
  2991.         sscanf(pathname,"/%s/%s", directory, filename);
  2992.     STRBEG                                                           STRBEG
  2993.     
  2994.     
  2995.     
  2996.     PROTOTYPE:
  2997.     
  2998.         int strbeg(char *string1, char *string2)
  2999.     
  3000.     
  3001.     ARGUMENTS:
  3002.     
  3003.         string1 - Pointer to character string to test
  3004.         string2 - Pointer to character string to check for
  3005.     
  3006.     
  3007.     RETURN VALUE:
  3008.     
  3009.         0   - String1 does not begin with string2
  3010.         1   - String1 begins with string2
  3011.     
  3012.     
  3013.     DECRIPTION:
  3014.     
  3015.           Tests the passed "string1" to determine if it begins with the same
  3016.        data as is contained within "string2".
  3017.     
  3018.     
  3019.     EXAMPLES:
  3020.     
  3021.         if(strbeg(command, "delete"))
  3022.             delete_file(&command[6]);
  3023.     STRCAT                                                           STRCAT
  3024.     
  3025.     
  3026.     
  3027.     PROTOTYPE:
  3028.     
  3029.         char *strcat(char *dest, *source)
  3030.     
  3031.     
  3032.     ARGUMENTS:
  3033.     
  3034.         dest    - Pointer to destination string
  3035.         source  - Pointer to source string
  3036.     
  3037.     
  3038.     RETURN VALUE:
  3039.     
  3040.         Pointer to zero terminating destination string
  3041.     
  3042.     
  3043.     DESCRIPTION:
  3044.     
  3045.           This function concatinates the source string onto the tail of  the
  3046.        destination string. The destination string must be  large  enough  to
  3047.        hold the entire contents of both strings.
  3048.     
  3049.     
  3050.     EXAMPLES:
  3051.     
  3052.         strcat(program_name, ".c");
  3053.     STRCHR                                                           STRCHR
  3054.     
  3055.     
  3056.     
  3057.     PROTOTYPE:
  3058.     
  3059.         char *strchr(char *string, char chr)
  3060.     
  3061.     
  3062.     ARGUMENTS:
  3063.     
  3064.         string  - Pointer to a character string
  3065.         chr     - Character to look for
  3066.     
  3067.     
  3068.     RETURN VALUE:
  3069.     
  3070.         Pointer to the first occurance of 'chr' in 'string'
  3071.         Zero (0) if character was not found
  3072.     
  3073.     
  3074.     DECRIPTION:
  3075.     
  3076.           Searches  the  passed  string  got  the  first  occurance  of  the
  3077.        specified character. If the character is  found,  a  pointer  to  its
  3078.        position in the string is returned. If the character is not found,  a
  3079.        null pointer is returned.
  3080.     
  3081.           The null (0) character is treated as valid data by this  function,
  3082.        thus:
  3083.           strchr(string, 0);
  3084.     
  3085.        would return the position of the null terminator of the string.
  3086.     
  3087.     
  3088.     EXAMPLES:
  3089.     
  3090.         comma = strchr(buffer, ',');
  3091.     STRCMP                                                           STRCMP
  3092.     
  3093.     
  3094.     
  3095.     PROTOTYPE:
  3096.     
  3097.         int strcmp(char *string1, char *string2)
  3098.     
  3099.     
  3100.     ARGUMENTS:
  3101.     
  3102.         string1 - Pointer to first string
  3103.         string2 - Pointer to second string
  3104.     
  3105.     
  3106.     RETURN VALUE:
  3107.     
  3108.         0   - Strings match exactly
  3109.         1   - String1 is greater than string2
  3110.         -1  - String2 is greater than string1
  3111.     
  3112.     
  3113.     DESCRIPTION:
  3114.     
  3115.           This function compares two strings character by character. If  the
  3116.        two strings are identical, a zero  (0)  is  returned.  If  the  first
  3117.        string is greater than the second (as far as ASCII is  concerned),  a
  3118.        one (1) is returned. If the second string is greater, a negative  one
  3119.        (-1) is returned.
  3120.     
  3121.     
  3122.     EXAMPLES:
  3123.     
  3124.         if(!strcmp(command, "quit"))
  3125.             exit(0);
  3126.     STRCPY                                                           STRCPY
  3127.     
  3128.     
  3129.     
  3130.     PROTOTYPE:
  3131.     
  3132.         char *strcpy(char *dest, char *source)
  3133.     
  3134.     
  3135.     ARGUMENTS:
  3136.     
  3137.         dest    - Pointer to destination string
  3138.         souce   - Pointer to source string
  3139.     
  3140.     
  3141.     RETURN VALUE:
  3142.     
  3143.         Pointer to zero terminating destination string
  3144.     
  3145.     
  3146.     DESCRIPTION:
  3147.     
  3148.           This function copies the source string to the destination  string.
  3149.        All data is copied up to and including the zero byte which terminates
  3150.        the string. The destination string must be large enough to  hold  the
  3151.        entire source.
  3152.     
  3153.     
  3154.     EXAMPLES:
  3155.     
  3156.         strcpy(filename, argv[1]);
  3157.     STRLEN                                                           STRLEN
  3158.     
  3159.     
  3160.     
  3161.     PROTOTYPE:
  3162.     
  3163.         int strlen(char *string)
  3164.     
  3165.     
  3166.     ARGUMENTS:
  3167.     
  3168.         string  - Pointer to a character string
  3169.     
  3170.     
  3171.     RETURN VALUE:
  3172.     
  3173.         The length of the string
  3174.     
  3175.     
  3176.     DECRIPTION:
  3177.     
  3178.           Returns the length in character of the passed string.  The  length
  3179.        does not include the zero byte which terminates the string.
  3180.     
  3181.     
  3182.     EXAMPLES:
  3183.     
  3184.         length = strlen(command);
  3185.     STRNCAT                                                         STRNCAT
  3186.     
  3187.     
  3188.     
  3189.     PROTOTYPE:
  3190.     
  3191.         char *strncat(char *dest, *source, unsigned length)
  3192.     
  3193.     
  3194.     ARGUMENTS:
  3195.     
  3196.         dest    - Pointer to destination string
  3197.         source  - Pointer to source string
  3198.         length  - Maximum number of characters to copy
  3199.     
  3200.     
  3201.     RETURN VALUE:
  3202.     
  3203.         Pointer to zero terminating destination string
  3204.     
  3205.     
  3206.     DESCRIPTION:
  3207.     
  3208.           This function concatinates the source string onto the tail of  the
  3209.        destination string. If the source string exceeds  "length"  bytes  in
  3210.        size, only that many characters are copied.
  3211.     
  3212.     
  3213.     EXAMPLES:
  3214.     
  3215.         strncat(path, filename, 64);
  3216.     STRNCMP                                                         STRNCMP
  3217.     
  3218.     
  3219.     
  3220.     PROTOTYPE:
  3221.     
  3222.         int strncmp(char *string1, char *string2, unsigned length)
  3223.     
  3224.     
  3225.     ARGUMENTS:
  3226.     
  3227.         string1 - Pointer to first string
  3228.         string2 - Pointer to second string
  3229.         length  - Number of bytes to compare
  3230.     
  3231.     
  3232.     RETURN VALUE:
  3233.     
  3234.         0   - Strings match exactly
  3235.         1   - String1 is greater than string2
  3236.         -1  - String2 is greater than string1
  3237.     
  3238.     
  3239.     DESCRIPTION:
  3240.     
  3241.           This function compares two strings character  by  character  until
  3242.        either a difference is detected, or  "length"  characters  have  been
  3243.        compared. If the two string portions are identical,  a  zero  (0)  is
  3244.        returned. If the first string is greater than the second (as  far  as
  3245.        ASCII is concerned), a one (1) is returned. If the second  string  is
  3246.        greater, a negative one (-1) is returned.
  3247.     
  3248.     
  3249.     EXAMPLES:
  3250.     
  3251.         len = strlen(buffer) - 3;
  3252.         for(i=1; i < len; ++i)
  3253.             if(strncmp(&buffer[i], "***", 3)
  3254.                 abort("Found three stars\n");
  3255.     STRNCPY                                                         STRNCPY
  3256.     
  3257.     
  3258.     
  3259.     PROTOTYPE:
  3260.     
  3261.         strncpy(char *dest, char *source, unsigned length)
  3262.     
  3263.     
  3264.     ARGUMENTS:
  3265.     
  3266.         dest    - Pointer to destination string
  3267.         souce   - Pointer to source string
  3268.         length  - Number of bytes to copy
  3269.     
  3270.     
  3271.     RETURN VALUE:
  3272.     
  3273.         None
  3274.     
  3275.     
  3276.     DESCRIPTION:
  3277.     
  3278.           This function copies "length" characters from the source string to
  3279.        the  destination  string.  If  the  source  string  is  shorter  than
  3280.        "length", the destination string is padded with nulls. If the  source
  3281.        string is longer than "length", only that many characters are copied,
  3282.        and the destination string is NOT zero terminated.
  3283.     
  3284.     
  3285.     EXAMPLES:
  3286.     
  3287.         strncpy(filename, argv[1], 64);
  3288.     STRSTR                                                           STRSTR
  3289.     
  3290.     
  3291.     
  3292.     PROTOTYPE:
  3293.     
  3294.         char *strstr(char *string1, char *string2)
  3295.     
  3296.     
  3297.     ARGUMENTS:
  3298.     
  3299.         string1 - Pointer to character string to test
  3300.         string2 - Pointer to substring to search for
  3301.     
  3302.     
  3303.     RETURN VALUE:
  3304.     
  3305.         Pointer to substring, or 0 if not found
  3306.     
  3307.     
  3308.     DECRIPTION:
  3309.     
  3310.           Searches the passed "string1"  for  the  first  occurance  of  the
  3311.        passed "string2". If found,  a  pointer  to  the  beginning  of  that
  3312.        substring within "string1" is returned.
  3313.     
  3314.     
  3315.     EXAMPLES:
  3316.     
  3317.         if(ptr = strstr(command, "delete"))
  3318.             delete_file(&ptr[6]);
  3319.     SYSTEM                                                           SYSTEM
  3320.     
  3321.     
  3322.     
  3323.     PROTOTYPE:
  3324.     
  3325.         int system(char *command)
  3326.     
  3327.     
  3328.     ARGUMENTS:
  3329.     
  3330.         command - A system command to be executed
  3331.     
  3332.     
  3333.     RETURN VALUE:
  3334.     
  3335.         0 if successful, otherwise an operating system error code
  3336.     
  3337.     
  3338.     DESCRIPTION:
  3339.     
  3340.           The SYSTEM function accepts any  operating  system  command  as  a
  3341.        string parameter, and passes that command to the operating system  to
  3342.        be executed.
  3343.     
  3344.           When the command has terminated,  execution  will  resume  in  the
  3345.        MICRO-C program, with the statement following the call to SYSTEM.
  3346.     
  3347.     
  3348.     EXAMPLES:
  3349.     
  3350.         system("DEL *.TMP");
  3351.     TOLOWER                                                         TOLOWER
  3352.     
  3353.     
  3354.     
  3355.     PROTOTYPE:
  3356.     
  3357.         char tolower(char c)
  3358.     
  3359.     
  3360.     ARGUMENTS:
  3361.     
  3362.         c   - Any character value
  3363.     
  3364.     
  3365.     RETURN VALUE:
  3366.     
  3367.         The value of 'c', converted to lower case
  3368.     
  3369.     
  3370.     DESCRIPTION:
  3371.     
  3372.           Returns the value of 'c' converted to lower case. If 'c' is not  a
  3373.        letter of upper case, no change is made, and the  original  value  of
  3374.        'c' is returned.
  3375.     
  3376.     
  3377.     EXAMPLES:
  3378.     
  3379.         input_char = tolower(getc(stdin));
  3380.     TOUPPER                                                         TOUPPER
  3381.     
  3382.     
  3383.     
  3384.     PROTOTYPE:
  3385.     
  3386.         char toupper(char c)
  3387.     
  3388.     
  3389.     ARGUMENTS:
  3390.     
  3391.         c   - Any character value
  3392.     
  3393.     
  3394.     RETURN VALUE:
  3395.     
  3396.         The value of 'c', converted to upper case
  3397.     
  3398.     
  3399.     DESCRIPTION:
  3400.     
  3401.           Returns the value of 'c' converted to upper case. If 'c' is not  a
  3402.        letter of lower case, no change is made, and the  original  value  of
  3403.        'c' is returned.
  3404.     
  3405.     
  3406.     EXAMPLES:
  3407.     
  3408.         putc(toupper(output_char), stdout);
  3409.     WRITE                                                             WRITE
  3410.     
  3411.     
  3412.     
  3413.     PROTOTYPE:
  3414.     
  3415.         int write(char *block, int size, HANDLE fh)
  3416.     
  3417.     
  3418.     ARGUMENTS:
  3419.     
  3420.         block   - Pointer to a block of data to write
  3421.         size    - Number of bytes to write
  3422.         fh      - File handle of an output file
  3423.     
  3424.     
  3425.     RETURN VALUE:
  3426.     
  3427.         0 if successful, otherwise an operating system error code
  3428.     
  3429.     
  3430.     DESCRIPTION:
  3431.     
  3432.           This function writes a block of data to the indicated  file  using
  3433.        low level (unbuffered) I/O from memory at the specified address. Data
  3434.        is  written  in  "raw"  form,  with  no  translations  of   "newline"
  3435.        characters etc. If the value returned is less than the value  of  the
  3436.        "size" parameter, some error condition  has  occured  (Such  as  disk
  3437.        full).
  3438.     
  3439.     
  3440.     EXAMPLES:
  3441.     
  3442.         if(write(buffer, 100, fh) < 100)
  3443.             abort("File write error\n");
  3444.     MICRO-C Library                                                  Page: 3
  3445.  
  3446.  
  3447.     
  3448.                       +---------------------------------+
  3449.                       |                                 |
  3450.                       |  *****************************  |
  3451.                       |  * The IBM-PC/MS-DOS library *  |
  3452.                       |  *****************************  |
  3453.                       |                                 |
  3454.                       +---------------------------------+
  3455.     
  3456.     
  3457.     
  3458.     
  3459.     
  3460.     
  3461.     
  3462.     
  3463.     
  3464.     
  3465.        1.2 IBM-PC/MS-DOS Library
  3466.     
  3467.              The library functions described  on  the  following  pages  are
  3468.           available only under the MS-DOS operating  system,  on  IBM-PC  or
  3469.           compatible systems.
  3470.     
  3471.              These routines perform operations which are closely tied to the
  3472.           8086 family of processors, the  IBM-PC  hardware,  or  the  MS-DOS
  3473.           operating system, and are therefore impractical to implement on  a
  3474.           "general" basis.
  3475.     ALLOCA                                                           ALLOCA
  3476.     
  3477.     
  3478.     
  3479.     PROTOTYPE:
  3480.     
  3481.         char *alloca(int size)
  3482.     
  3483.     
  3484.     ARGUMENTS:
  3485.     
  3486.         size    - Size of memory block to allocate (in bytes).
  3487.     
  3488.     
  3489.     RETURN VALUE:
  3490.     
  3491.         0       - Memory allocation failed
  3492.         !0      - Pointer to allocated memory
  3493.     
  3494.     
  3495.     DESCRIPTION:
  3496.     
  3497.           The "alloca" function  allocates  a  block  of  automatic  (stack)
  3498.        memory, which exists only only until the  function  calling  "alloca"
  3499.        returns. When that function returns, all stack memory  including  any
  3500.        allocated by "alloca" is released.
  3501.     
  3502.        NOTE: THE FOLLOWING RESTRICTIONS APPLY TO THE USE OF ALLOCA:
  3503.     
  3504.           The function calling 'alloca' MUST have  at  least  one  automatic
  3505.        (local) variable, otherwise MICRO-C will not  restore  the  stack  on
  3506.        exit.
  3507.     
  3508.           The 'alloca' function must be used within a simple expression,  at
  3509.        a point where there will be no partial results stored on the stack.
  3510.     
  3511.           The above conditions can best be met by declaring a local  pointer
  3512.        which will hold the memory address, and assigning it the value of the
  3513.        'alloca' call in a single statement. The address returned by 'alloca'
  3514.        should NOT be assigned to a calculated  address  (such  as  an  array
  3515.        element or indirect reference via a pointer), since this  may  result
  3516.        in stack activity.
  3517.     
  3518.           NOTE: The size operand to 'alloca' can be  a  complex  expression,
  3519.        since any stack operations it causes will have dissipated by the time
  3520.        'alloca' gets called.
  3521.     
  3522.     
  3523.     EXAMPLES:
  3524.     
  3525.     func(string)
  3526.         char *string;
  3527.     {
  3528.         char *local_memory;
  3529.     
  3530.         if(!(local_memory = alloca(strlen(string)+1)))
  3531.             abort("Not enough memory for alloca");
  3532.         /* ... */
  3533.     }
  3534.     ALLOC_SEG                                                     ALLOC_SEG
  3535.     
  3536.     
  3537.     
  3538.     PROTOTYPE:
  3539.     
  3540.         int alloc_seg(int size)
  3541.     
  3542.     
  3543.     ARGUMENTS:
  3544.     
  3545.         size    - Number of 16 byte paragraphs to allocate
  3546.     
  3547.     
  3548.     RETURN VALUE:
  3549.     
  3550.     
  3551.         0       - Not enough free memory available
  3552.         !0      - The segment address of the allocated memory
  3553.     
  3554.     
  3555.     DESCRIPTION:
  3556.     
  3557.           The "alloc_seg" function allocates a 'segment' of memory from DOS.
  3558.        The size is given in 16 byte "paragraphs". The allocated memory  will
  3559.        be outside of the data memory available to the MICRO-C  program,  and
  3560.        therefore must be accessed via assembly lenguage functions,  or  with
  3561.        the "peek" and "poke" library functions.
  3562.     
  3563.     
  3564.     EXAMPLES:
  3565.     
  3566.         if(!(aseg = alloc(4096)))   /* Get a 64K data segment */
  3567.             abort("Not enough memory!!!");
  3568.         set_es(aseg);               /* Set up extra segment */
  3569.         asm_func();                 /* Invoke assembler function */
  3570.     BREAK                                                             BREAK
  3571.     
  3572.     
  3573.     
  3574.     PROTOTYPE:
  3575.     
  3576.         break(int allow)
  3577.     
  3578.     
  3579.     ARGUMENTS:
  3580.     
  3581.         allow   - 0 = disallow break, !0 = allow breaks
  3582.     
  3583.     
  3584.     RETURN VALUE:
  3585.     
  3586.         None
  3587.     
  3588.     
  3589.     DESCRIPTION:
  3590.     
  3591.           Controls the setting of the DOS "break" flag. When set  on  (allow
  3592.        != 0), the keyboard is tested for CONTROL-BREAK on any  DOS  function
  3593.        call. If set off (allow == 0), CONTROL-C is  only  recognized  during
  3594.        I/O to the keyboard and video display.
  3595.     
  3596.     
  3597.     EXAMPLES:
  3598.     
  3599.         break(1);   /* Disable keyboard interrupts */
  3600.     CCLOSE                                                           CCLOSE
  3601.     
  3602.     
  3603.     
  3604.     PROTOTYPE:
  3605.     
  3606.         Cclose()
  3607.     
  3608.     
  3609.     ARGUMENTS:
  3610.     
  3611.         None
  3612.     
  3613.     
  3614.     RETURN VALUE:
  3615.     
  3616.         None
  3617.     
  3618.     
  3619.     DESCRIPTION:
  3620.     
  3621.           This function closes the  communications  port  previously  opened
  3622.        using "Copen". The system interrupt vectors and all  other  hooks  to
  3623.        the comm port are restored.
  3624.     
  3625.           This function must be called  before  any  program  using  "Copen"
  3626.        terminates, otherwise the communications port  will  be  left  in  an
  3627.        indeterminate state. If this is not done, there will be a possibility
  3628.        of system crash if an interrupt is received from the port  after  the
  3629.        program has terminated.
  3630.     
  3631.     
  3632.     EXAMPLES:
  3633.     
  3634.         Cclose();       /* Close comm port */
  3635.         exit(0);        /* And terminate */
  3636.     CGETC                                                             CGETC
  3637.     
  3638.     
  3639.     
  3640.     PROTOTYPE:
  3641.     
  3642.         int Cgetc()
  3643.     
  3644.     
  3645.     ARGUMENTS:
  3646.     
  3647.         None
  3648.     
  3649.     
  3650.     RETURN VALUE:
  3651.     
  3652.         Character read from the communications port
  3653.     
  3654.     
  3655.     DESCRIPTION:
  3656.     
  3657.           This function reads a single  character  from  the  communications
  3658.        port previously opened with "Copen". If no  character  is  available,
  3659.        "Cgetc" will wait for one.
  3660.     
  3661.     
  3662.     EXAMPLES:
  3663.     
  3664.         /* Get a string from the comm port */
  3665.         while((c = cgetc()) != '\r')
  3666.             *ptr++ = c;
  3667.         *ptr = 0;
  3668.     COPEN                                                             COPEN
  3669.     
  3670.     
  3671.     
  3672.     PROTOTYPE:
  3673.     
  3674.         int Copen(int port, int speed, int mode, int modem)
  3675.     
  3676.     
  3677.     ARGUMENTS:
  3678.     
  3679.         port    - Comm port to use (1, 2, 3 or 4)
  3680.         speed   - Baudrate divisor to set
  3681.         mode    - Communications parameters to set
  3682.         modem   - Modem control lines to set
  3683.     
  3684.     RETURN VALUE:
  3685.     
  3686.         0       - Successful open
  3687.         !0      - Requested comm port is not available
  3688.     
  3689.     
  3690.     DESCRIPTION:
  3691.     
  3692.           The "Copen" function opens a serial communications port on the IBM
  3693.        PC for access. An independant interrupt handler and I/O  drivers  are
  3694.        installed, which allow high speed full duplex operation of the serial
  3695.        port with optional XON/XOFF flow control of both receive and transmit
  3696.        streams.
  3697.     
  3698.           Only one serial port  may  be  accessed  at  a  time  using  these
  3699.        functions, If "Copen" is called more than once, it will automatically
  3700.        close the last port before opening the new one.
  3701.     
  3702.           The meaning of the "speed",  "mode",  and  "modem"  parameters  if
  3703.        documented in the "comm.h" header file.
  3704.     
  3705.           An external "char" variable "Cflags" may be accessed to enable  or
  3706.        disable transparency of the serial  channel.  When  "transparent"  is
  3707.        selected, XON/XOFF flow control is disabled, and all data is sent and
  3708.        received with no changes. When  operating  in  this  mode,  you  must
  3709.        insure that "Cgetc" is called frequently enough  that  the  256  byte
  3710.        internal receive buffer will not overflow.
  3711.     
  3712.           Since "Cflags" is  used  by  the  interrupt  handler,  you  should
  3713.        disable and enable interrupts around any accesses to it.
  3714.     
  3715.     
  3716.     
  3717.     EXAMPLES:
  3718.     
  3719.         #include comm.h     /* Get comm port defintions */
  3720.     
  3721.             extern char Cflags;
  3722.     
  3723.         /*
  3724.          * Program to read & echo characters on the serial port
  3725.          * in transparent mode. (Until ESCAPE char is received)
  3726.          */
  3727.         main()
  3728.         {
  3729.             char c;
  3730.     
  3731.             if(Copen(1, _2400, PAR_NO|DATA_8|STOP_1, SET_RTS|SET_DTR))
  3732.                 abort("Cannot access COM1");
  3733.     
  3734.             disable();                  /* Disable interrupts */
  3735.             Cflags |= TRANSPARENT;      /* Set transparency */
  3736.             enable();                   /* Re-enable interrupts */
  3737.     
  3738.             while((c = Cgetc()) != 0x1B)    /* Do until ESCAPE */
  3739.                 Cputc(c);
  3740.     
  3741.             Cclose();                   /* Close the serial port */
  3742.         }
  3743.     COPY_SEG                                                       COPY_SEG
  3744.     
  3745.     
  3746.     
  3747.     PROTOTYPE:
  3748.     
  3749.         copy_seg(int dseg, int doffset, int sseg, int soffset, int size)
  3750.     
  3751.     
  3752.     ARGUMENTS:
  3753.     
  3754.         dseg    - Destination segment
  3755.         doffset - Destination offset
  3756.         sseg    - Source segment
  3757.         soffset - Source offset
  3758.         size    - Number of bytes to copy
  3759.     
  3760.     
  3761.     RETURN VALUE:
  3762.     
  3763.         None
  3764.     
  3765.     
  3766.     DESCRIPTION:
  3767.     
  3768.           This function  perform  a  copy  between  80X86  processor  memory
  3769.        segments. A number of bytes equal to "size" is copied from the source
  3770.        segment and offset to the destination segment and offset.
  3771.     
  3772.     
  3773.     EXAMPLES:
  3774.     
  3775.         /* Save the video display contents */
  3776.         copy_seg(get_ds(), buffer, _V_BASE, 0, (25*80)*2);
  3777.     CPU                                                                 CPU
  3778.     
  3779.     
  3780.     
  3781.     PROTOTYPE:
  3782.     
  3783.         int cpu()
  3784.     
  3785.     
  3786.     ARGUMENTS:
  3787.     
  3788.         None
  3789.     
  3790.     
  3791.     RETURN VALUE:
  3792.     
  3793.         0       - CPU is 8088 or 8086
  3794.         1       - CPU is 80188 or 80186
  3795.         2       - CPU is 80286
  3796.         3       - CPU is 80386 or 80486
  3797.     
  3798.     
  3799.     DESCRIPTION:
  3800.     
  3801.           This function  returns  a  simple  integer  which  identifies  the
  3802.        processor type on which the program is currently executing.
  3803.     
  3804.     
  3805.     EXAMPLES:
  3806.     
  3807.         if(cpu() < 2)
  3808.             abort("This program requires at least an 80286");
  3809.     CPUTC                                                             CPUTC
  3810.     
  3811.     
  3812.     
  3813.     PROTOTYPE:
  3814.     
  3815.         Cputc(char c)
  3816.     
  3817.     
  3818.     ARGUMENTS:
  3819.     
  3820.         c       - Character to write to communciation port
  3821.     
  3822.     
  3823.     RETURN VALUE:
  3824.     
  3825.         None
  3826.     
  3827.     
  3828.     DESCRIPTION:
  3829.     
  3830.           The  "Cputc"  function  writes  the   given   character   to   the
  3831.        communcinations port previously opened by "Copen".
  3832.     
  3833.     
  3834.     EXAMPLES:
  3835.     
  3836.         while(*ptr)         /* Write a string to comm port */
  3837.             Cputc(*ptr++);
  3838.     CSIGNALS                                                       CSIGNALS
  3839.     
  3840.     
  3841.     
  3842.     PROTOTYPE:
  3843.     
  3844.         int Csignals()
  3845.     
  3846.     
  3847.     ARGUMENTS:
  3848.     
  3849.         None
  3850.     
  3851.     
  3852.     RETURN VALUE:
  3853.     
  3854.         The modem input signals read from the open comm port
  3855.     
  3856.     
  3857.     DESCRIPTION:
  3858.     
  3859.           This function reads the modem input signals (DSR, CD, RI etc) from
  3860.        the serial communication  port  previously  opened  by  "Copen",  and
  3861.        returns them as an integer value.
  3862.     
  3863.           The meaning of the  individual  bits  in  the  value  returned  by
  3864.        "Csignals" is documented in the "comm.h" header file.
  3865.     
  3866.     
  3867.     EXAMPLES:
  3868.     
  3869.         if(!(Csignals() & DSR)) {
  3870.             Cclose();
  3871.             abort("Modem not ready"); }
  3872.     CTESTC                                                           CTESTC
  3873.     
  3874.     
  3875.     
  3876.     PROTOTYPE:
  3877.     
  3878.         int Ctestc()
  3879.     
  3880.     
  3881.     ARGUMENTS:
  3882.     
  3883.         None
  3884.     
  3885.     
  3886.     RETURN VALUE:
  3887.     
  3888.         0-255   - Character read from comm port
  3889.         -1      - No character available
  3890.     
  3891.     
  3892.     DESCRIPTION:
  3893.     
  3894.           This function tests for a character from the  communications  port
  3895.        previously opened with "Copen", and returns that character if one  if
  3896.        found. If no character is available, "Ctestc" returns -1.
  3897.     
  3898.     
  3899.     EXAMPLES:
  3900.     
  3901.         if((c = Ctestc()) == -1) {
  3902.             Cclose();
  3903.             abort("No character available"); }
  3904.     DELAY                                                             DELAY
  3905.     
  3906.     
  3907.     
  3908.     PROTOTYPE:
  3909.     
  3910.         delay(int msec)
  3911.     
  3912.     
  3913.     ARGUMENTS:
  3914.     
  3915.         msec    - Number of milliseconds to wait
  3916.     
  3917.     
  3918.     RETURN VALUE:
  3919.     
  3920.         None
  3921.     
  3922.     
  3923.     DESCRIPTION:
  3924.     
  3925.           Pauses for the specified number of milliseconds. This function  is
  3926.        limited to the accuracy of the BIOS clock,  which  operates  at  18.2
  3927.        ticks per second.
  3928.     
  3929.     
  3930.     EXAMPLES:
  3931.     
  3932.         delay(1000);        /* Wait one second */
  3933.     DISABLE                                                         DISABLE
  3934.     
  3935.     
  3936.     
  3937.     PROTOTYPE:
  3938.     
  3939.         disable()
  3940.     
  3941.     
  3942.     ARGUMENTS:
  3943.     
  3944.         None
  3945.     
  3946.     
  3947.     RETURN VALUE:
  3948.     
  3949.         None
  3950.     
  3951.     
  3952.     DESCRIPTION:
  3953.     
  3954.           The  "disable"  function  disables  the  8086  interrupt   system,
  3955.        preventing the  processor  from  servicing  interrupts.  It  is  used
  3956.        whenever the execution of an interrupt handler may interfere  with  a
  3957.        particular operation.
  3958.     
  3959.           When this function is used, the "enable" function should be called
  3960.        as soon as possible after "disable". Failure to do this may result in
  3961.        loss  of  system  functions  performed  under  interrupts,  such   as
  3962.        timekeeping, and serial communications (Via MICRO-C serial drivers).
  3963.     
  3964.     
  3965.     EXAMPLES:
  3966.     
  3967.         disable();                  /* Disallow interrupts */
  3968.         Cflags &= ~TRANSPARENT;     /* Remove transparency */
  3969.         enable();                   /* Re-allow interrupts */
  3970.     ENABLE                                                           ENABLE
  3971.     
  3972.     
  3973.     
  3974.     PROTOTYPE:
  3975.     
  3976.         enable()
  3977.     
  3978.     
  3979.     ARGUMENTS:
  3980.     
  3981.         None
  3982.     
  3983.     
  3984.     RETURN VALUE:
  3985.     
  3986.         None
  3987.     
  3988.     
  3989.     DESCRIPTION:
  3990.     
  3991.           The "enable" function enables the 8086 interrupt system,  allowing
  3992.        the processor to service interrupts. It should be called as  soon  as
  3993.        possible following the use of the "disable" function.
  3994.     
  3995.     
  3996.     EXAMPLES:
  3997.     
  3998.         disable();                  /* Disallow interrupts */
  3999.         Cflags |= TRANSPARENT;      /* Force  transparency */
  4000.         enable();                   /* Re-allow interrupts */
  4001.     EXEC                                                               EXEC
  4002.     
  4003.     
  4004.     
  4005.     PROTOTYPE:
  4006.     
  4007.         int exec(char *exefile, char *args)
  4008.     
  4009.     
  4010.     ARGUMENTS:
  4011.     
  4012.         exefile - Full pathname of a '.COM' or '.EXE' file
  4013.         args    - Command tail containing arguments
  4014.     
  4015.     
  4016.     RETURN VALUE:
  4017.     
  4018.         0 if successful, otherwise an MS-DOS error code
  4019.     
  4020.     
  4021.     DESCRIPTION:
  4022.     
  4023.           The "exec" function causes MS-DOS to suspend the execution of  the
  4024.        MICRO-C program, and then to execute the indicated '.EXE'  or  '.COM'
  4025.        program file. When that program terminates, execution of the  MICRO-C
  4026.        program will resume.
  4027.     
  4028.           This is a low level interface to the MS-DOS 'EXEC'  function,  and
  4029.        as such, it does not search your PATH, does not process '.BAT' files,
  4030.        nor provide any I/O redirection facilities. If you want to  make  use
  4031.        of these features (which are  provided  by  'COMMAND.COM'),  use  the
  4032.        higher level 'SYSTEM' function.
  4033.     
  4034.     
  4035.     EXAMPLES:
  4036.     
  4037.         printf("Type 'EXIT' to return to the MICRO-C program\n");
  4038.         exec("C:\\COMMAND.COM", "");    /* Start up a sub-shell */
  4039.     FREE_SEG                                                       FREE_SEG
  4040.     
  4041.     
  4042.     
  4043.     PROTOTYPE:
  4044.     
  4045.         int free_seg(int segment)
  4046.     
  4047.     
  4048.     ARGUMENTS:
  4049.     
  4050.         segment - A previously allocated segment of memory
  4051.     
  4052.     
  4053.     RETURN VALUE:
  4054.     
  4055.         0       - The segment was released
  4056.         !0      - DOS error code
  4057.     
  4058.     
  4059.     DESCRIPTION:
  4060.     
  4061.           The "free_seg" function releases a segment  of  memory  previously
  4062.        allocated by "alloc_seg", and returns it  to  the  operating  system.
  4063.        This should be used whenever your program has finished with a segment
  4064.        of extra memory which it has allocated.
  4065.     
  4066.     
  4067.     EXAMPLES:
  4068.     
  4069.         aseg = alloc_seg(4096);         /* Allocate a 64K segment */
  4070.         set_es(aseg);                   /* Set up extra segment */
  4071.         asm_func();                     /* Call assembler function */
  4072.         free_seg(aseg);                 /* Releas the memory */
  4073.     GET_ATTR                                                       GET_ATTR
  4074.     
  4075.     
  4076.     
  4077.     PROTOTYPE:
  4078.     
  4079.         int get_attr(char *pathname, int &attrs)
  4080.     
  4081.     
  4082.     ARGUMENTS:
  4083.     
  4084.         pathname- Name of file to get attributes of
  4085.         attrs   - Integer to receive attributes
  4086.     
  4087.     
  4088.     RETURN VALUE:
  4089.     
  4090.         0 if successful, otherwise an operating system error code
  4091.     
  4092.     
  4093.     DESCRIPTION:
  4094.     
  4095.           This function retreives the attributes of the specified file.
  4096.     
  4097.           The meaning of the individual bits in the "attrs" value is defined
  4098.        in the "file.h" header file.
  4099.     
  4100.     
  4101.     EXAMPLES:
  4102.     
  4103.         get_attr("tempfile", &attributes);
  4104.     GET_CS                                                           GET_CS
  4105.     
  4106.     
  4107.     
  4108.     PROTOTYPE:
  4109.     
  4110.         int get_cs()
  4111.     
  4112.     
  4113.     ARGUMENTS:
  4114.     
  4115.         None
  4116.     
  4117.     
  4118.     RETURN VALUE:
  4119.     
  4120.         The current processor CODE segment
  4121.     
  4122.     
  4123.     DESCRIPTION:
  4124.     
  4125.           This function is available only on the 8086 family of  processors,
  4126.        and returns the current processor CODE segment.
  4127.     
  4128.     
  4129.     EXAMPLES:
  4130.     
  4131.         code_seg = get_cs();
  4132.     GET_DATE                                                       GET_DATE
  4133.     
  4134.     
  4135.     
  4136.     PROTOTYPE:
  4137.     
  4138.         get_date(int &day, int &month, int &year)
  4139.     
  4140.     
  4141.     ARGUMENTS:
  4142.     
  4143.         &day    - Address of integer to receive day (1-31)
  4144.         &month  - Address of integer to receive month (1-12)
  4145.         &year   - Address of integer to receive year (1980-2099)
  4146.     
  4147.     
  4148.     RETURN VALUE:
  4149.     
  4150.         Day of week (0=Sun ... 6=Sat)
  4151.     
  4152.     
  4153.     DESCRIPTION:
  4154.     
  4155.           This function gets the current system  date  in  day,  month,  and
  4156.        year.
  4157.     
  4158.     
  4159.     EXAMPLES:
  4160.     
  4161.         get_date(&day, &month, &year);
  4162.         printf("%s %u, %u", months[month], day, year);
  4163.     GET_DRIVE                                                     GET_DRIVE
  4164.     
  4165.     
  4166.     
  4167.     PROTOTYPE:
  4168.     
  4169.         int get_drive()
  4170.     
  4171.     
  4172.     ARGUMENTS:
  4173.     
  4174.         None
  4175.     
  4176.     
  4177.     RETURN VALUE:
  4178.     
  4179.         The currently active (default) disk drive (0=A, 1=B, 2=C, ...)
  4180.     
  4181.     
  4182.     DESCRIPTION:
  4183.     
  4184.           The "get_drive" function returns the  drive  index  (0-n)  of  the
  4185.        currently active or "default" MS-DOS disk drive.
  4186.     
  4187.     
  4188.     EXAMPLES:
  4189.     
  4190.         old_drive = get_drive();
  4191.         set_drive(new_drive);
  4192.     GET_DS                                                           GET_DS
  4193.     
  4194.     
  4195.     
  4196.     PROTOTYPE:
  4197.     
  4198.         int get_ds()
  4199.     
  4200.     
  4201.     ARGUMENTS:
  4202.     
  4203.         None
  4204.     
  4205.     
  4206.     RETURN VALUE:
  4207.     
  4208.         The current processor DATA segment
  4209.     
  4210.     
  4211.     DESCRIPTION:
  4212.     
  4213.           This function is available only on the 8086 family of  processors,
  4214.        and returns the current processor DATA segment.
  4215.     
  4216.     
  4217.     EXAMPLES:
  4218.     
  4219.         data_seg = get_ds();
  4220.     GET_ES                                                           GET_ES
  4221.     
  4222.     
  4223.     
  4224.     PROTOTYPE:
  4225.     
  4226.         int get_es()
  4227.     
  4228.     
  4229.     ARGUMENTS:
  4230.     
  4231.         None
  4232.     
  4233.     
  4234.     RETURN VALUE:
  4235.     
  4236.         The current processor EXTRA segment
  4237.     
  4238.     
  4239.     DESCRIPTION:
  4240.     
  4241.           This function is available only on the 8086 family of  processors,
  4242.        and returns the current processor EXTRA segment.
  4243.     
  4244.     
  4245.     EXAMPLES:
  4246.     
  4247.         code_seg = get_es();
  4248.     GET_TIME                                                       GET_TIME
  4249.     
  4250.     
  4251.     
  4252.     PROTOTYPE:
  4253.     
  4254.         get_time(int &hour, int &minite, int &second)
  4255.     
  4256.     
  4257.     ARGUMENTS:
  4258.     
  4259.         &hour   - Address of integer to receive hour (0-23)
  4260.         &minite - Address of integer to receive minite (0-59)
  4261.         &second - Address of integer to receive second (0-59)
  4262.     
  4263.     
  4264.     RETURN VALUE:
  4265.     
  4266.         None
  4267.     
  4268.     
  4269.     DESCRIPTION:
  4270.     
  4271.           This function gets the current system time in hours,  minites  and
  4272.        seconds.
  4273.     
  4274.     
  4275.     EXAMPLES:
  4276.     
  4277.         get_time(&hour, &minite, &second);
  4278.         printf("%02:%02:%02", hour, minite, second);
  4279.     INT86                                                             INT86
  4280.     
  4281.     
  4282.     
  4283.     PROTOTYPE:
  4284.     
  4285.         int int86(int inum)
  4286.     
  4287.     
  4288.     ARGUMENTS:
  4289.     
  4290.         inum    - The 8086 software interrupt to execute
  4291.     
  4292.     
  4293.     RETURN VALUE:
  4294.     
  4295.         8086 FLAGS register after interrupt executes.
  4296.     
  4297.     
  4298.     DESCRIPTION:
  4299.     
  4300.           This  function  performs  an  8086  software   interrupt.   Before
  4301.        executing the interrupt, the processor registers are loaded from  the
  4302.        external "int" variables: _AX_, _BX_, _CX_, _DX_, _SI_ and _DI_.  The
  4303.        DS, ES and SS segment registers are all set  to  point  to  MICRO-C's
  4304.        data segment.
  4305.     
  4306.           After the interrupt  completes,  the  contents  of  the  processor
  4307.        registers are copied to the above named variables.
  4308.     
  4309.     
  4310.     EXAMPLES:
  4311.     
  4312.         extern int _AX_, _DX_;
  4313.         main() {
  4314.             _AX_ = 0x0200;  /* MSDOS function 2 - Output character */
  4315.             _DX_ = '$';     /* Character to output */
  4316.             int86(0x21);    /* Call MSDOS */
  4317.         }
  4318.     RESIZE_SEG                                                   RESIZE_SEG
  4319.     
  4320.     
  4321.     
  4322.     PROTOTYPE:
  4323.     
  4324.         int resize_seg(int segment, int size)
  4325.     
  4326.     
  4327.     ARGUMENTS:
  4328.     
  4329.         segment - A previously allocated segment of memory
  4330.         size    - Desired size (in 16 byte paragraphs)
  4331.     
  4332.     
  4333.     RETURN VALUE:
  4334.     
  4335.         0       - The segments size has been adjusted
  4336.         !0      - DOS error code
  4337.     
  4338.     
  4339.     DESCRIPTION:
  4340.     
  4341.           The "resize_seg" function provides a method of changing  the  size
  4342.        of a segment of memory previously allocated via "alloc_seg".  If  not
  4343.        enough memory is available, the function will fail  with  a  ono-zero
  4344.        return value.
  4345.     
  4346.           This function may also be used to adjust the memoey allocation  of
  4347.        the programs image, by passing it the segment address of the programs
  4348.        own PSP. This value is available in the external variable "PSP".
  4349.     
  4350.           MICRO-C normally allocates 64K for programs compiled in  the  TINY
  4351.        model, and (64K + (256 byte PSP) + (size  of  executable  code))  for
  4352.        programs compiled in the SMALL model. This allocation should NEVER be
  4353.        reduced, however you may enlarge it if your program wishes to  access
  4354.        additional data immediately following its own DATA/STACK segment.
  4355.     
  4356.     
  4357.     EXAMPLES:
  4358.     
  4359.         extern int PSP;
  4360.     
  4361.         main()
  4362.         {
  4363.             if(resize_seg(PSP, 8192))   /* Append 64K buffer */
  4364.                 abort("Not enough memory!!!");
  4365.             ...     /* Remainder of program */
  4366.         }
  4367.     RESTORE_VIDEO                                             RESTORE_VIDEO
  4368.     
  4369.     
  4370.     
  4371.     PROTOTYPE:
  4372.     
  4373.         restore_video(char buffer[4006]);
  4374.     
  4375.     
  4376.     ARGUMENTS:
  4377.     
  4378.         buffer  - Video save area.
  4379.     
  4380.     
  4381.     RETURN VALUE:
  4382.     
  4383.         None
  4384.     
  4385.     
  4386.     DESCRIPTION:
  4387.     
  4388.           The RESTORE_VIDEO function restores the contents and state of  the
  4389.        IBM P.C. video display to the state it was in when  "SAVE_VIDEO"  was
  4390.        executed. At the present time, the function  is  effective  only  for
  4391.        text modes. Graphics screens will not be restored, due  to  the  high
  4392.        memory requirements.
  4393.     
  4394.           Although this function is useful in ANY program  (to  restore  the
  4395.        DOS screen before termination), it is most  useful  in  "POP-UP"  ram
  4396.        resident programs (See "TSR" function), to save  the  screen  of  any
  4397.        application which may be running when you pop up.
  4398.     
  4399.           The video state is restored from  the  passed  "buffer"  argument,
  4400.        which is 4006 bytes  in  size,  and  must  have  been  filled  in  by
  4401.        "SAVE_VIDEO". It has the following format:
  4402.     
  4403.                   buffer[0]         - Video mode
  4404.                     "   [1]         - Video page
  4405.                     "   [2]         - 'X' cursor position
  4406.                     "   [3]         - 'Y' cursor position
  4407.                     "   [4]         - Ending line for cursor
  4408.                     "   [5]         - Starting line for cursor
  4409.                     "   [6-4005]    - Saved video screen contents
  4410.     
  4411.     
  4412.     EXAMPLES:
  4413.     
  4414.         popup_func()
  4415.         {
  4416.             save_video();
  4417.             perform_function();
  4418.             restore_video();
  4419.         }
  4420.     SAVE_VIDEO                                                   SAVE_VIDEO
  4421.     
  4422.     
  4423.     
  4424.     PROTOTYPE:
  4425.     
  4426.         save_video(char buffer[4006]);
  4427.     
  4428.     
  4429.     ARGUMENTS:
  4430.     
  4431.         buffer  - Video save area.
  4432.     
  4433.     
  4434.     RETURN VALUE:
  4435.     
  4436.         None
  4437.     
  4438.     
  4439.     DESCRIPTION:
  4440.     
  4441.           The SAVE_VIDEO function saves the current contents  and  state  of
  4442.        the IBM P.C. video display. The screen may be restored  at  any  time
  4443.        using "RESTORE_VIDEO". At the present time, the function is effective
  4444.        only for text modes. Graphics screens will not be saved, due  to  the
  4445.        high memory requirements.
  4446.     
  4447.           Although this function is useful in ANY program  (to  restore  the
  4448.        DOS screen before termination), it is most  useful  in  "POP-UP"  ram
  4449.        resident programs (See "TSR" function), to save  the  screen  of  any
  4450.        application which may be running when you pop up.
  4451.     
  4452.           The video state is saved in the passed "buffer" argument, which is
  4453.        4006 bytes in size, and has the following format:
  4454.     
  4455.                   buffer[0]         - Video mode
  4456.                     "   [1]         - Video page
  4457.                     "   [2]         - 'X' cursor position
  4458.                     "   [3]         - 'Y' cursor position
  4459.                     "   [4]         - Ending line for cursor
  4460.                     "   [5]         - Starting line for cursor
  4461.                     "   [6-4005]    - Saved video screen contents
  4462.     
  4463.     
  4464.     EXAMPLES:
  4465.     
  4466.         popup_func()
  4467.         {
  4468.             save_video();
  4469.             perform_function();
  4470.             restore_video();
  4471.         }
  4472.     SET_ATTR                                                       SET_ATTR
  4473.     
  4474.     
  4475.     
  4476.     PROTOTYPE:
  4477.     
  4478.         int set_attr(char *pathname, int attrs)
  4479.     
  4480.     
  4481.     ARGUMENTS:
  4482.     
  4483.         pathname- Name of file to get attributes of
  4484.         attrs   - New attributes
  4485.     
  4486.     
  4487.     RETURN VALUE:
  4488.     
  4489.         0 if successful, otherwise an operating system error code
  4490.     
  4491.     
  4492.     DESCRIPTION:
  4493.     
  4494.           This function sets the system attributes of the specified file.
  4495.     
  4496.           The meaning of the individual bits in the "attrs" value is defined
  4497.        in the "file.h" header file.
  4498.     
  4499.     
  4500.     EXAMPLES:
  4501.     
  4502.         set_attr("tempfile", READONLY|HIDDEN);
  4503.     SET_DATE                                                       SET_DATE
  4504.     
  4505.     
  4506.     
  4507.     PROTOTYPE:
  4508.     
  4509.         set_date(int day, int month, int year)
  4510.     
  4511.     
  4512.     ARGUMENTS:
  4513.     
  4514.         day     - New day (1-31)
  4515.         month   - New month (1-12)
  4516.         year    - New year (1980-2099)
  4517.     
  4518.     
  4519.     RETURN VALUE:
  4520.     
  4521.         0       - Success
  4522.         -1      - Invalid date given
  4523.     
  4524.     
  4525.     DESCRIPTION:
  4526.     
  4527.           This function sets the current system  date  to  day,  month,  and
  4528.        year.
  4529.     
  4530.     
  4531.     EXAMPLES:
  4532.     
  4533.         set_date(1, 1, 1980);   /* Set to Jan 1, 1980 */
  4534.     SET_DRIVE                                                     SET_DRIVE
  4535.     
  4536.     
  4537.     
  4538.     PROTOTYPE:
  4539.     
  4540.         int set_drive(int drive)
  4541.     
  4542.     
  4543.     ARGUMENTS:
  4544.     
  4545.         Drive   - New drive index (0=A, 1=B, 2=C ...)
  4546.     
  4547.     
  4548.     RETURN VALUE:
  4549.     
  4550.         The total number of "logical" disk drives in the system
  4551.     
  4552.     
  4553.     DESCRIPTION:
  4554.     
  4555.           The "set_drive" function sets the  disk  drive  indicated  by  the
  4556.        "drive" index (0-x) to be the currently active  or  "default"  MS-DOS
  4557.        disk drive.
  4558.     
  4559.     
  4560.     EXAMPLES:
  4561.     
  4562.         old_drive = get_drive();
  4563.         set_drive(new_drive);
  4564.     SET_ES                                                           SET_ES
  4565.     
  4566.     
  4567.     
  4568.     PROTOTYPE:
  4569.     
  4570.         int set_es(int segment)
  4571.     
  4572.     
  4573.     ARGUMENTS:
  4574.     
  4575.         segment - The 16 bit new segment value
  4576.     
  4577.     
  4578.     RETURN VALUE:
  4579.     
  4580.         None
  4581.     
  4582.     
  4583.     DESCRIPTION:
  4584.     
  4585.           This function is available only on the 8086 family of  processors,
  4586.        and sets the processors EXTRA segment to the indicated value.
  4587.     
  4588.     
  4589.     EXAMPLES:
  4590.     
  4591.         set_es(get_ds());       /* Copy DATA to EXTRA segments */
  4592.     SET_TIME                                                       SET_TIME
  4593.     
  4594.     
  4595.     
  4596.     PROTOTYPE:
  4597.     
  4598.         set_time(int hour, int minite, int second)
  4599.     
  4600.     
  4601.     ARGUMENTS:
  4602.     
  4603.         hour    - New hour (0-23)
  4604.         minite  - New minite (0-59)
  4605.         second  - New second (0-59)
  4606.     
  4607.     
  4608.     RETURN VALUE:
  4609.     
  4610.         0       - Success
  4611.         -1      - Invalid time given
  4612.     
  4613.     
  4614.     DESCRIPTION:
  4615.     
  4616.           This function sets the current system time to "hour", "minite" and
  4617.        "second".
  4618.     
  4619.     
  4620.     EXAMPLES:
  4621.     
  4622.         set_time(0, 0, 0);  /* Set to 00:00:00 (midnight) */
  4623.     TSR                                                                 TSR
  4624.     
  4625.     
  4626.     
  4627.     PROTOTYPE:
  4628.     
  4629.         tsr(&func, int hotkey, int alloc)
  4630.     
  4631.     
  4632.     ARGUMENTS:
  4633.     
  4634.         func    - Address of function to execute
  4635.         hotkey  - POP-UP activation hotkeys
  4636.         alloc   - Memory allocation
  4637.     
  4638.     
  4639.     RETURN VALUE:
  4640.     
  4641.         Function normally never returns, but if it does, an
  4642.         operating system error code is passed back.
  4643.     
  4644.     
  4645.     DESCRIPTION:
  4646.     
  4647.           The TSR function terminates the MICRO-C  program,  but  leaves  it
  4648.        resident in memory. When the specified "HOT KEYS" are detected on the
  4649.        IBM PC keyboard, the context of whatever program is running is saved,
  4650.        and the specified MICRO-C function  is  called.  When  that  function
  4651.        returns, the interrupted program is resumed.
  4652.     
  4653.           When activated this way, THE "func" FUNCTION  MUST  NOT  TERMINATE
  4654.        WITH "exit" or one of its related functions (abort  etc.).  THE  ONLY
  4655.        WAY IT MAY TERMINATE IS TO "return" NORMALLY.
  4656.     
  4657.           The meaning of "hotkey" is defined in the "tsr.h" header file.
  4658.     
  4659.           The "alloc" paremeter specifies how much extra  memory  is  to  be
  4660.        retained in the TSR image for use  by  the  MICRO-C  stack  and  heap
  4661.        memory allocation functions. The "func" function(s) must insure  that
  4662.        the total amount of memory used by the stack and  calls  to  "malloc"
  4663.        does not exceed this value.
  4664.     
  4665.           NOTE: "malloc" will fail if the heap grows to  within  1K  of  the
  4666.        stack pointer.
  4667.     
  4668.           All memory used by  code,  global  variables,  string  space,  and
  4669.        "malloc" calls prior to the use of "tsr" is  automatically  retained,
  4670.        and should not be included in the "alloc" value.
  4671.     
  4672.           TSR programs which perform screen I/O should take care to save and
  4673.        restore the screen contents when popping up and down.
  4674.     
  4675.     
  4676.     EXAMPLES:
  4677.     
  4678.         tsr(&popup_func, ALT+L_SHIFT, 1024);
  4679.     VCLEAR_BOX                                                   VCLEAR_BOX
  4680.     
  4681.     
  4682.     
  4683.     PROTOTYPE:
  4684.     
  4685.         vclear_box(int x, int y, int w, int h)
  4686.     
  4687.     
  4688.     ARGUMENTS:
  4689.     
  4690.         x       - COLUMN of top left corner of box
  4691.         y       - ROW of top left corner of box
  4692.         w       - Width of box (columns)
  4693.         h       - Height of box (rows)
  4694.     
  4695.     
  4696.     RETURN VALUE:
  4697.     
  4698.         None
  4699.     
  4700.     
  4701.     DESCRIPTION:
  4702.     
  4703.           This function clears a box of the specified height and  width,  at
  4704.        the indicated 'X' and 'Y' coordinates, on  the  IBM-PC  video  screen
  4705.        using the block graphics characters. The entire  box  is  cleared  to
  4706.        spaces.
  4707.     
  4708.           "VOPEN" MUST be called prior to using this function.
  4709.     
  4710.     
  4711.     EXAMPLES:
  4712.     
  4713.         vclear_box(21, 11, 8, 3);   /* Clear a BOX */
  4714.     VCLEOL                                                           VCLEOL
  4715.     
  4716.     
  4717.     
  4718.     PROTOTYPE:
  4719.     
  4720.         vcleol()
  4721.     
  4722.     
  4723.     ARGUMENTS:
  4724.     
  4725.         None
  4726.     
  4727.     
  4728.     RETURN VALUE:
  4729.     
  4730.         None
  4731.     
  4732.     
  4733.     DESCRIPTION:
  4734.     
  4735.           This function clears the IBM PC  video  screen  from  the  current
  4736.        cursor position to the end of a line.
  4737.     
  4738.           You must "#include video.h", and execute "VOPEN"  prior  to  using
  4739.        this function.
  4740.     
  4741.     
  4742.     EXAMPLES:
  4743.     
  4744.         vprintf("Input> ");     /* Display a prompt */
  4745.         vcleol();               /* Clear remainder of input line */
  4746.     VCLEOS                                                           VCLEOS
  4747.     
  4748.     
  4749.     
  4750.     PROTOTYPE:
  4751.     
  4752.         vcleos()
  4753.     
  4754.     
  4755.     ARGUMENTS:
  4756.     
  4757.         None
  4758.     
  4759.     
  4760.     RETURN VALUE:
  4761.     
  4762.         None
  4763.     
  4764.     
  4765.     DESCRIPTION:
  4766.     
  4767.           This function clears the IBM PC  video  screen  from  the  current
  4768.        cursor position to the end of a screen.
  4769.     
  4770.           "VOPEN" MUST be called prior to using this function.
  4771.     
  4772.     
  4773.     EXAMPLES:
  4774.     
  4775.         vgotoxy(0, 10);         /* position at line 11 */
  4776.         vcleos();               /* Clear lower part of screen */
  4777.     VCLSCR                                                           VCLSCR
  4778.     
  4779.     
  4780.     
  4781.     PROTOTYPE:
  4782.     
  4783.         vclscr()
  4784.     
  4785.     
  4786.     ARGUMENTS:
  4787.     
  4788.         None
  4789.     
  4790.     
  4791.     RETURN VALUE:
  4792.     
  4793.         None
  4794.     
  4795.     
  4796.     DESCRIPTION:
  4797.     
  4798.           This function clears the entire IBM PC video screen and resets the
  4799.        cursor position to the top left hand corner.
  4800.     
  4801.           "VOPEN" MUST be called prior to using this function.
  4802.     
  4803.     
  4804.     EXAMPLES:
  4805.     
  4806.         if(c = 0x1b) {          /* Escape command */
  4807.             vclscr();       /* Clear the screen */
  4808.             vprintf("%s has terminated\n", argv[0]);
  4809.             exit(-1); }
  4810.     VCURSOR_BLOCK                                             VCURSOR_BLOCK
  4811.     
  4812.     
  4813.     
  4814.     PROTOTYPE:
  4815.     
  4816.         vcursor_block()
  4817.     
  4818.     
  4819.     ARGUMENTS:
  4820.     
  4821.         None
  4822.     
  4823.     
  4824.     RETURN VALUE:
  4825.     
  4826.         None
  4827.     
  4828.     
  4829.     DESCRIPTION:
  4830.     
  4831.           This function enables (turns on) display of the cursor on the  IBM
  4832.        PC video display. The cursor is shown as  flashing  block,  occupying
  4833.        the entire character window.
  4834.     
  4835.           "VOPEN" MUST be called prior to using this function.
  4836.     
  4837.     
  4838.     EXAMPLES:
  4839.     
  4840.         if(insert)              /* Test insert mode flag */
  4841.             vcursor_block();    /* Indicate inserting with block cursor */
  4842.         else
  4843.             vcursor_line();     /* Indicate overwrite with line cursor */
  4844.     VCURSOR_LINE                                               VCURSOR_LINE
  4845.     
  4846.     
  4847.     
  4848.     PROTOTYPE:
  4849.     
  4850.         vcursor_line()
  4851.     
  4852.     
  4853.     ARGUMENTS:
  4854.     
  4855.         None
  4856.     
  4857.     
  4858.     RETURN VALUE:
  4859.     
  4860.         None
  4861.     
  4862.     
  4863.     DESCRIPTION:
  4864.     
  4865.           This function enables (turns on) display of the cursor on the  IBM
  4866.        PC video display. The cursor is shown as a single flashing  line,  at
  4867.        the bottom of the character window.
  4868.     
  4869.           "VOPEN" MUST be called prior to using this function.
  4870.     
  4871.     
  4872.     EXAMPLES:
  4873.     
  4874.         vcursor_line();     /* Re-enable the cursor */
  4875.         exit(0);            /* And terminate */
  4876.     VCURSOR_OFF                                                 VCURSOR_OFF
  4877.     
  4878.     
  4879.     
  4880.     PROTOTYPE:
  4881.     
  4882.         vcursor_off()
  4883.     
  4884.     
  4885.     ARGUMENTS:
  4886.     
  4887.         None
  4888.     
  4889.     
  4890.     RETURN VALUE:
  4891.     
  4892.         None
  4893.     
  4894.     
  4895.     DESCRIPTION:
  4896.     
  4897.           This function inhibits (turns off) display of the  cursor  on  the
  4898.        IBM PC video display. This affects the cursor  display  only,  screen
  4899.        output will continue to be displayed at the correct cursor position.
  4900.     
  4901.           "VOPEN" MUST be called prior to using this function.
  4902.     
  4903.     
  4904.     EXAMPLES:
  4905.     
  4906.         vclscr();           /* Clear screen */
  4907.         vcursor_off();      /* Inhibit cursor */
  4908.         vmenu(10, 10, main_menu, 0, &index);    /* Present main menu */
  4909.     VDRAW_BOX                                                     VDRAW_BOX
  4910.     
  4911.     
  4912.     
  4913.     PROTOTYPE:
  4914.     
  4915.         vdraw_box(int x, int y, int w, int h)
  4916.     
  4917.     
  4918.     ARGUMENTS:
  4919.     
  4920.         x       - COLUMN of top left corner of box
  4921.         y       - ROW of top left corner of box
  4922.         w       - Width of box (columns)
  4923.         h       - Height of box (rows)
  4924.     
  4925.     
  4926.     RETURN VALUE:
  4927.     
  4928.         None
  4929.     
  4930.     
  4931.     DESCRIPTION:
  4932.     
  4933.           This function draws a box of the specified height  and  width,  at
  4934.        the indicated 'X' and 'Y' coordinates, on  the  IBM-PC  video  screen
  4935.        using the block graphics characters.
  4936.     
  4937.           "VOPEN" MUST be called prior to using this function.
  4938.     
  4939.     
  4940.     EXAMPLES:
  4941.     
  4942.         vdraw_box(20, 10, 10, 5);   /* Draw a BOX */
  4943.     VERSION                                                         VERSION
  4944.     
  4945.     
  4946.     
  4947.     PROTOTYPE:
  4948.     
  4949.         int version()
  4950.     
  4951.     
  4952.     ARGUMENTS:
  4953.     
  4954.         None
  4955.     
  4956.     
  4957.     RETURN VALUE:
  4958.     
  4959.         MS-DOS operating system version number
  4960.     
  4961.     
  4962.     DESCRIPTION:
  4963.     
  4964.           The "version" function is available only under MS-DOS, and returns
  4965.        the version number of the operating system.
  4966.     
  4967.           The higher 8 bits  of  the  returned  value  indicates  the  MAJOR
  4968.        version number ('3' in DOS 3.1)
  4969.     
  4970.           The lower 8 bits of the returned value indicates the MINOR version
  4971.        nuber ('1' in DOS 3.1).
  4972.     
  4973.     
  4974.     EXAMPLES:
  4975.     
  4976.         if(version() < 0x031E)
  4977.             abort("Requires DOS 3.30 or higher\n");
  4978.     VGETC                                                             VGETC
  4979.     
  4980.     
  4981.     
  4982.     PROTOTYPE:
  4983.     
  4984.         int vgetc()
  4985.     
  4986.     
  4987.     ARGUMENTS:
  4988.     
  4989.         None
  4990.     
  4991.     
  4992.     RETURN VALUE:
  4993.     
  4994.         0-127   - ASCII value of key pressed
  4995.         < 0     - Special function key as defined in "video.h"
  4996.     
  4997.     
  4998.     DESCRIPTION:
  4999.     
  5000.           The "vgetc" function waits until a key is pressed  on  the  system
  5001.        console, and returns its value.
  5002.     
  5003.           Note that due to the  buffering  of  the  IBM-PC  keyboard,  every
  5004.        keypress will be reported, even if the VGETC function is called after
  5005.        a key is pressed and released.
  5006.     
  5007.     
  5008.     EXAMPLES:
  5009.     
  5010.         switch(vgetc()) {       /* Handle input keys
  5011.                 . . .
  5012.         }
  5013.     VGETS                                                             VGETS
  5014.     
  5015.     
  5016.     
  5017.     PROTOTYPE:
  5018.     
  5019.         int vgets(int x, int y, char *prompt, char *field, int width)
  5020.     
  5021.     
  5022.     ARGUMENTS:
  5023.     
  5024.         x       - COLUMN of top left corner of input box
  5025.         y       - ROW of top left corner of input box
  5026.         prompt  - String to prompt with
  5027.         field   - String to receive the data
  5028.         width   - Width in characters of input field
  5029.     
  5030.     
  5031.     RETURN VALUE:
  5032.     
  5033.         0   - Selection was made and ENTER pressed.
  5034.         !0  - Input was aborted via ESCAPE key.
  5035.     
  5036.     
  5037.     DESCRIPTION:
  5038.     
  5039.           The "vgets" function draws a  box  on  the  video  screen  at  the
  5040.        specified X and Y coordinates, then prompts for and receives an input
  5041.        string in the box. The box is  drawn  large  enough  to  contain  the
  5042.        prompt and  the  specified  width  of  input  field.  The  prompt  is
  5043.        displayed at the left hand  side  of  the  box,  and  the  cursor  is
  5044.        positioned immediatly following it, at the start of the input field.
  5045.     
  5046.           The "field" parameter is the  address  of  a  character  array  to
  5047.        receive the input string. The previous value of the "field" array  is
  5048.        inserted into the input box when VGETS is invoked. If you do not want
  5049.        to display an old value, you should set the first  character  pointed
  5050.        to by field to zero, before calling VGETS.
  5051.     
  5052.           When entering the string, the user may use the  following  special
  5053.        keys to edit the input field:
  5054.     
  5055.                 Right Arrow - Move forward one character
  5056.                 Left  Arrow - Move backward one character
  5057.                 Delete      - Delete the character under the cursor
  5058.                 Backspace   - Move backward one character and delete.
  5059.                 Home        - Move to beginning of string
  5060.                 End         - Move to end of string
  5061.                 PgUp        - Clear (erase) entire string
  5062.                 PgDn        - Clear from cursor to end of string
  5063.                 Enter       - Accept (enter) the string
  5064.                 ESC         - Abort the input request
  5065.     
  5066.           All data entered in the input box is inserted into any data  which
  5067.        is already present.
  5068.     
  5069.     
  5070.     
  5071.     EXAMPLES:
  5072.     
  5073.         name[0] = 0;
  5074.         if(vgets(10, 10, "Your name?", name, 30))
  5075.             return;     /* Aborted, exit to higher level */
  5076.     VGOTOXY                                                         VGOTOXY
  5077.     
  5078.     
  5079.     
  5080.     PROTOTYPE:
  5081.     
  5082.         vgotoxy(int x, int y)
  5083.     
  5084.     
  5085.     ARGUMENTS:
  5086.     
  5087.         x       - New COLUMN (0-79)
  5088.         y       - New ROW    (0-24)
  5089.     
  5090.     
  5091.     RETURN VALUE:
  5092.     
  5093.         None
  5094.     
  5095.     
  5096.     DESCRIPTION:
  5097.     
  5098.           The "vgotoxy" function positions the cursor on  the  IBM-PC  video
  5099.        screen. Any further display output will occur  at  the  new  ROW  and
  5100.        COLUMN on the screen.
  5101.     
  5102.           The extern "int" variable "V_XY" may be referenced to read or  set
  5103.        the  current  X/Y  position.  The  higher  8  bits  contain  the  'Y'
  5104.        coordinate, and the lower 8 bits contain the 'X' coordinate. If  this
  5105.        variable is used to set (restore) the  cursor  position,  "vupdatexy"
  5106.        must then be called to position the physical cursor.
  5107.     
  5108.           "VOPEN" MUST be called prior to using this function.
  5109.     
  5110.     
  5111.     EXAMPLES:
  5112.     
  5113.         for(i=0; i<24; ++i) {   /* Draw a diagonal line of 'X's */
  5114.             vgotoxy(i, i);
  5115.             vputc('X'); }
  5116.     VMENU                                                             VMENU
  5117.     
  5118.     
  5119.     
  5120.     PROTOTYPE:
  5121.     
  5122.         vmenu(int x, int y, char *names[], char erase, int &index)
  5123.     
  5124.     
  5125.     ARGUMENTS:
  5126.     
  5127.         x       - COLUMN of top left corner of menu box
  5128.         y       - ROW of top left corner of menu box
  5129.         names   - Array to menu selection text (last entry = 0)
  5130.         erase   - 1=Erase BOX after selection is made
  5131.         index   - Address of message selection index variable
  5132.     
  5133.     
  5134.     RETURN VALUE:
  5135.     
  5136.         0   - Selection was made and ENTER pressed.
  5137.         !0  - Menu was aborted via ESCAPE key.
  5138.     
  5139.     
  5140.     DESCRIPTION:
  5141.     
  5142.           The "vmenu" function displays a list of menu items enclosed  in  a
  5143.        box on the IBM-PC video  screen  at  the  specified  ROW  and  COLUMN
  5144.        address. The user may use the UP, DOWN, HOME and END keys  to  select
  5145.        an entry by moving the INVERSE VIDEO selection cursor.
  5146.     
  5147.           When the desired selection is under the cursor, the  selection  is
  5148.        made by pressing the ENTER key.
  5149.     
  5150.           At any time the menu selection may be  canceled  by  pressing  the
  5151.        ESCAPE key.
  5152.     
  5153.           The "names" argument must be a pointer to an  array  of  character
  5154.        strings which are the selections to display. This array MUST end with
  5155.        a zero (0) element to indicate the end of the list.
  5156.     
  5157.           The "erase" flag indicates that the menu box should be cleared  to
  5158.        blanks when the selection is made. If "erase=0", the menu box is left
  5159.        on the screen, WITHOUT the selection cursor, with the selected  entry
  5160.        marked by '>' and '<'. The menu box is always erased when the menu is
  5161.        aborted with the ESCAPE key.
  5162.     
  5163.           The "index" argument is the address of  an  "int"  variable  which
  5164.        contains the position of the selection cursor. It controls where  the
  5165.        selection cursor will appear when the function is first invoked (0  =
  5166.        first entry), and also is assigned  the  position  of  the  selection
  5167.        cursor when the selection is made.
  5168.     
  5169.     
  5170.     
  5171.     EXAMPLES:
  5172.     
  5173.         char *names[] = { "One", "Two", "Three", "Four", "Five", 0 };
  5174.             . . .
  5175.         index = 0;
  5176.         if(vmenu(10, 10, names, 0, &index))
  5177.             return;         /* Aborted, exit to higher level */
  5178.         switch(index) {     /* Handle selection */
  5179.             . . .
  5180.         }
  5181.     VMESSAGE                                                       VMESSAGE
  5182.     
  5183.     
  5184.     
  5185.     PROTOTYPE:
  5186.     
  5187.         vmessage(int x, int y, char *string)
  5188.     
  5189.     
  5190.     ARGUMENTS:
  5191.     
  5192.         x       - COLUMN of top left corner of message box
  5193.         y       - ROW of top left corner of message box
  5194.         string  - Message to display
  5195.     
  5196.     
  5197.     RETURN VALUE:
  5198.     
  5199.         None
  5200.     
  5201.     
  5202.     DESCRIPTION:
  5203.     
  5204.           The "vmessage" function displays a text  string  surrounded  by  a
  5205.        BOX, on the IBM-PC video screen, at  the  specified  ROW  and  COLUMN
  5206.        address.
  5207.     
  5208.           "VOPEN" MUST be called prior to using this function.
  5209.     
  5210.     
  5211.     EXAMPLES:
  5212.     
  5213.         vmessage(20, 20, "Press any KEY to continue");
  5214.         get_key();
  5215.         vclear_box(20, 20, 26, 2);
  5216.     VOPEN                                                             VOPEN
  5217.     
  5218.     
  5219.     
  5220.     PROTOTYPE:
  5221.     
  5222.         vopen()
  5223.     
  5224.     
  5225.     ARGUMENTS:
  5226.     
  5227.         None
  5228.     
  5229.     
  5230.     RETURN VALUE:
  5231.     
  5232.         None
  5233.     
  5234.     
  5235.     DESCRIPTION:
  5236.     
  5237.           This function initializes the IBM-PC video display adapter for use
  5238.        with the MICRO-C video library functions. It determines  the  adapter
  5239.        type  (COLOR  ot  MONOCHROME),  sets  up  internal   variables   with
  5240.        information required by the other video  functions,  and  clears  the
  5241.        video screen.
  5242.     
  5243.           This function MUST  be  called  before  any  of  the  other  video
  5244.        functions in the library are used.
  5245.     
  5246.           After "vopen" is called, the extern "int" variable "V_BASE" may be
  5247.        referenced to determine the memory segment of the video display (B000
  5248.        for monochrome, B800 for color).
  5249.     
  5250.           Any program using the video library  functions  must  include  the
  5251.        "video.h" header file.
  5252.     
  5253.     
  5254.     EXAMPLES:
  5255.     
  5256.         vopen();
  5257.     VPRINTF                                                         VPRINTF
  5258.     
  5259.     
  5260.     
  5261.     PROTOTYPE:
  5262.     
  5263.         register vprintf(char *format, arg, ...)
  5264.     
  5265.     
  5266.     ARGUMENTS:
  5267.     
  5268.         format  - Pointer to format string
  5269.         arg     - Argument as determined by format string
  5270.         ...     - Additional arguments may be required
  5271.     
  5272.     
  5273.     RETURN VALUE:
  5274.     
  5275.         None
  5276.     
  5277.     
  5278.     DESCRIPTION:
  5279.     
  5280.           This function performs exactly as the  "PRINTF"  function  in  the
  5281.        standard function library, except that it  outputs  directly  to  the
  5282.        video screen using the video interface library routines.
  5283.     
  5284.           This function should be used in preference to "PRINTF" when  using
  5285.        the video function library since "PRINTF" will  not  move  the  video
  5286.        librarys cursor.
  5287.     
  5288.           NOTE: This function uses a variable number of arguments, and  must
  5289.        be declared as "register" (See "video.h").
  5290.     
  5291.           "VOPEN" MUST be called prior to using this function.
  5292.     
  5293.     
  5294.     EXAMPLES:
  5295.     
  5296.         vgotoxy(0, 0);
  5297.         vprintf("Screen %u", screen);
  5298.     VPUTC                                                             VPUTC
  5299.     
  5300.     
  5301.     
  5302.     PROTOTYPE:
  5303.     
  5304.         vputc(char chr)
  5305.     
  5306.     
  5307.     ARGUMENTS:
  5308.     
  5309.         chr     - Character to display
  5310.     
  5311.     
  5312.     RETURN VALUE:
  5313.     
  5314.         None
  5315.     
  5316.     
  5317.     DESCRIPTION:
  5318.     
  5319.           This function displays a character on  the  video  screen  at  the
  5320.        current cursor position.
  5321.     
  5322.           Characters are output in "tty" fashion, with  proper  handling  of
  5323.        control codes such as CARRIAGE-RETURN, LINE-FEED and BELL. The screen
  5324.        will scroll upwards when a NEWLINE is printed on the bottom  line  of
  5325.        the screen, or when the bottom line wraps around to the next.
  5326.     
  5327.           Although only the lower 8 bits of a passed value are used, "vputc"
  5328.        will not perform ANY output translations if any of the upper  8  bits
  5329.        are set. This provides a method of displaying  the  video  characters
  5330.        represented by control codes such as NEWLINE, and BACKSPACE.
  5331.     
  5332.           The external "char" variable "V_ATTR" may be used to set the video
  5333.        attribute used by "VPUTC" to display the  character.  This  value  is
  5334.        written to the attribute location associated with  the  character  on
  5335.        the video display hardware. Its effect  is  dependant  on  the  video
  5336.        adapter in use. The "video.h" header file contains definitions of the
  5337.        attribute bits for use on "standard" monochrome and color displays.
  5338.     
  5339.     
  5340.           "VOPEN" MUST be called prior to using this function.
  5341.     
  5342.     
  5343.     EXAMPLES:
  5344.     
  5345.         vputc(0x0A);            /* Line-feed, advance cursor */
  5346.         vputc(0x0A | 0xff00);   /* Display 0x0A character code */
  5347.     VPUTF                                                             VPUTF
  5348.     
  5349.     
  5350.     
  5351.     PROTOTYPE:
  5352.     
  5353.         vputf(char *string, int width)
  5354.     
  5355.     
  5356.     ARGUMENTS:
  5357.     
  5358.         string  - Pointer to character string
  5359.         width   - Width of output field
  5360.     
  5361.     
  5362.     RETURN VALUE:
  5363.     
  5364.         None
  5365.     
  5366.     
  5367.     DESCRIPTION:
  5368.     
  5369.           The "vputf" function outputs a  character  string  to  the  IBM-PC
  5370.        video screen using the video library functions.
  5371.     
  5372.           The string is left justified in a field of the specified width. If
  5373.        the string is shorter than "width", the field is padded with  blanks.
  5374.        If the string is longer than "width", the output is truncated.
  5375.     
  5376.           "VOPEN" MUST be called prior to using this function.
  5377.     
  5378.     
  5379.     EXAMPLES:
  5380.     
  5381.         vputf(message, 10); 
  5382.     VPUTS                                                             VPUTS
  5383.     
  5384.     
  5385.     
  5386.     PROTOTYPE:
  5387.     
  5388.         vputs(char *string)
  5389.     
  5390.     
  5391.     ARGUMENTS:
  5392.     
  5393.         string  - Pointer to character string
  5394.     
  5395.     
  5396.     RETURN VALUE:
  5397.     
  5398.         None
  5399.     
  5400.     
  5401.     DESCRIPTION:
  5402.     
  5403.           The "vputs" function outputs a  character  string  to  the  IBM-PC
  5404.        video screen using the video library functions.
  5405.     
  5406.           "VOPEN" MUST be called prior to using this function.
  5407.     
  5408.     
  5409.     EXAMPLES:
  5410.     
  5411.         vputs(message);
  5412.     VTSTC                                                             VTSTC
  5413.     
  5414.     
  5415.     
  5416.     PROTOTYPE:
  5417.     
  5418.         int vtstc()
  5419.     
  5420.     
  5421.     ARGUMENTS:
  5422.     
  5423.         None
  5424.     
  5425.     
  5426.     RETURN VALUE:
  5427.     
  5428.         0       - No key pressed
  5429.         1-127   - ASCII value of key pressed
  5430.         < 0     - Special function key as defined in "video.h"
  5431.     
  5432.     
  5433.     DESCRIPTION:
  5434.     
  5435.           The "vtstc" function  tests  for  a  key  pressed  on  the  system
  5436.        console, and  returns  its  value.  A  returned  value  of  zero  (0)
  5437.        indicates that no key was found to be pressed.
  5438.     
  5439.           Note that due to the  buffering  of  the  IBM-PC  keyboard,  every
  5440.        keypress will be reported, even if the VTSTC function is called after
  5441.        a key is pressed and released.
  5442.     
  5443.     
  5444.     EXAMPLES:
  5445.     
  5446.         if(vtstc() == 0x1B) /* exit loop on ESCAPE key */
  5447.             break;
  5448.     VUPDATEXY                                                     VUPDATEXY
  5449.     
  5450.     
  5451.     
  5452.     PROTOTYPE:
  5453.     
  5454.         vupdatexy()
  5455.     
  5456.     
  5457.     ARGUMENTS:
  5458.     
  5459.         None
  5460.     
  5461.     
  5462.     RETURN VALUE:
  5463.     
  5464.         None
  5465.     
  5466.     
  5467.     DESCRIPTION:
  5468.     
  5469.           This function updates the real X/Y cursor position  on  the  video
  5470.        screen to reflect the "logical" position  where  the  next  character
  5471.        will be output.
  5472.     
  5473.           The MICRO-C video library  uses  a  BIOS  interrupt  (INT  10)  to
  5474.        position the cursor, which is quite slow, compared to  the  speed  of
  5475.        the library video routines. To prevent this  from  slowing  down  the
  5476.        video output, the cursor is  only  physically  re-positioned  when  a
  5477.        "vgotoxy" or a "vgetc" is executed.
  5478.     
  5479.           This allows the library routines to run at full speed,  and  still
  5480.        put the cursor in the right place when  output  stops  and  an  input
  5481.        request is made.
  5482.     
  5483.           A side effect of this is that the cursor on the  screen  will  not
  5484.        appear to move unless  you  call  "vgotoxy"  or  "vgetc".  This  only
  5485.        affects the physical cursor on the screen, MICRO-C maintains its  own
  5486.        internal cursor location which it uses  to  determine  where  on  the
  5487.        screen the next write will occur.
  5488.     
  5489.           Some applications which run in  real  time  (Such  as  a  terminal
  5490.        emulator) do not call "vgetc", but use "vtstc" to poll  the  keyboard
  5491.        on a regular basis. In this case, the "vupdatexy" routine  should  be
  5492.        called any time that the visual position of the cursor is important.
  5493.     
  5494.           "VOPEN" MUST be called prior to using this function.
  5495.     
  5496.     
  5497.     EXAMPLES:
  5498.     
  5499.         vupdatexy();        /* position the cursor *
  5500.         c = vtstc();        /* Test for a character */
  5501.     MICRO-C Library                                                  Page: 4
  5502.  
  5503.  
  5504.     
  5505.                      +------------------------------------+
  5506.                      |                                    |
  5507.                      |  ********************************  |
  5508.                      |  * The IBM-PC WINDOWING library *  |
  5509.                      |  ********************************  |
  5510.                      |                                    |
  5511.                      +------------------------------------+
  5512.     
  5513.     
  5514.     
  5515.     
  5516.     
  5517.     
  5518.     
  5519.     
  5520.     
  5521.     
  5522.        1.3 IBM-PC WINDOWING Library
  5523.     
  5524.              The MICRO-C WINDOWING LIBRARY is a set of powerful, very  fast,
  5525.           compact, text based windowing functions for use with  the  MICRO-C
  5526.           compiler, on the IBM Personal Computer. Features  of  the  library
  5527.           include multiple open windows,  overlaid  windows  with  automatic
  5528.           save/restore  of  screen  underneath,  scrolling  within  windows,
  5529.           optional window borders, menu and form entry functions, and more.
  5530.     
  5531.              The library is organized into two parts, the first is a set  of
  5532.           assembly language routines which provides the  basic  "low  level"
  5533.           functions to open/close windows, and to output data in  them.  The
  5534.           second part of the library provides a set of 'C'  functions  which
  5535.           provide "high level"  functions  such  as  menu  and  form  entry,
  5536.           formatted printing, etc.
  5537.     MICRO-C Library                                                  Page: 5
  5538.  
  5539.  
  5540.           1.3.1 Window Control Block
  5541.     
  5542.                 Whenever a new window is opened, the windowing library  sets
  5543.              up a WINDOW CONTROL  BLOCK  (WCB)  which  contains  information
  5544.              needed to access and control the window. The format of the  WCB
  5545.              is:
  5546.     
  5547.         Offset: 0   - Current video attribute *
  5548.                 1   - Window flags (High 8 bits of w_open attrs) **
  5549.                 2   - Absolute 'X' position of top left corner of
  5550.                       active region. ***
  5551.                 3   - Absolute 'Y' position of top left corner of
  5552.                       active region. ***
  5553.                 4   - Width in characters of active region ***
  5554.                 5   - Height in characters of active region ***
  5555.                 6   - Current 'X' cursor coordinate
  5556.                 7   - Current 'Y' cursor coordinate
  5557.                 8,9 - Pointer to previous window buffer
  5558.                 10  - Previous cursor ENDING line
  5559.                 11  - Previous cursor STARTING line
  5560.                 12  - Previous cursor absolute 'X' position ****
  5561.                 13  - Previous cursor absolute 'Y' position ****
  5562.                 14..- Save area for SAVE/RESTORE function
  5563.     
  5564.         *       You may dynamically alter the video attribute of data
  5565.                 written to the window by writing to this byte.
  5566.     
  5567.         **      You may dynamically alter the properties of the window by
  5568.                 setting or clearing the flag bits with these exceptions:
  5569.                 -DO NOT enable SAVE/RESTORE unless opened with it
  5570.                 (It is Ok to disable SAVE/RESTORE).
  5571.                 -DO NOT change the state of the BORDER bits.
  5572.     
  5573.         ***     For windows opened with a BORDER, this reflects the size
  5574.                 of the active region (not including the border). Otherwise,
  5575.                 this is the size of the entire window.
  5576.     
  5577.         ****    For full screen window which does not SAVE/RESTORE, you can
  5578.                 set these values to zero to home cursor on exit.
  5579.     MICRO-C Library                                                  Page: 6
  5580.  
  5581.  
  5582.           1.3.2 External Variables
  5583.     
  5584.                 In addition to  the  functions  decribed  on  the  following
  5585.              pages, the windowing library provides  the  following  external
  5586.              variables which may be accessed from within your 'C' program:
  5587.     
  5588.              1.3.2.1 W_BASE
  5589.     
  5590.                                extern int W_BASE;
  5591.     
  5592.                    This variable contains the  base  address  of  the  video
  5593.                 screen, which may be used to determine the type  of  display
  5594.                 present:
  5595.     
  5596.                         B000 = Monochrome
  5597.                         B800 = Color
  5598.     
  5599.     
  5600.              1.3.2.2 W_OPEN
  5601.     
  5602.                               extern char *W_OPEN;
  5603.     
  5604.                    This variable contains a  pointer  to  the  WCB  for  the
  5605.                 "active" window, and controls which window is manipulated by
  5606.                 certain library functions.  This  automatically  set  up  by
  5607.                 "wopen" to point to the  last  window  opened,  but  may  be
  5608.                 changed at any time with:
  5609.     
  5610.                                 W_OPEN = window;
  5611.     
  5612.                    NOTE, when the active window is closed, W_OPEN  is  reset
  5613.                 to point to the window which was active at the time that  it
  5614.                 (the active window) was opened. If  windows  are  closed  in
  5615.                 other than the reverse order  of  which  they  were  opened,
  5616.                 W_OPEN may be left pointing to a window  which  has  already
  5617.                 been closed. If this happens, YOU MUST NOT USE THE  "ACTIVE"
  5618.                 WINDOW FUNCTIONS WITHOUT RESETTING W_OPEN  TO  POINT  TO  AN
  5619.                 OPEN WINDOW. It is your (the programmer's) responsibility to
  5620.                 insure that you know what window will  be  accessed  through
  5621.                 W_OPEN at all times throughout your program.
  5622.     
  5623.           1.3.3 Window Library Functions
  5624.     
  5625.                 The following pages contain a description of  each  function
  5626.              available in the IBM-PC windowing library.
  5627.     WCLEOL                                                           WCLEOL
  5628.     W_CLEOL                                                         W_CLEOL
  5629.     
  5630.     
  5631.     
  5632.     PROTOTYPE:
  5633.     
  5634.         wcleol()
  5635.         w_cleol(char *window)
  5636.     
  5637.     
  5638.     ARGUMENTS:
  5639.     
  5640.         window  - Pointer to WCB for an open window
  5641.     
  5642.     
  5643.     RETURN VALUE:
  5644.     
  5645.         None
  5646.     
  5647.     
  5648.     DESCRIPTION:
  5649.     
  5650.           The "wcleol" function clears the active window  from  the  current
  5651.        cursor position to the end of a line.
  5652.     
  5653.           The "w_cleol" function  clears  the  specified  window  fromt  the
  5654.        current position to the end of the line.
  5655.     
  5656.     
  5657.     EXAMPLES:
  5658.     
  5659.         wputs("Input> ");       /* Display a prompt */
  5660.         wcleol();               /* Clear remainder of input line */
  5661.     WCLEOW                                                           WCLEOW
  5662.     W_CLEOW                                                         W_CLEOW
  5663.     
  5664.     
  5665.     
  5666.     PROTOTYPE:
  5667.     
  5668.         wcleow()
  5669.         w_cleow(char *window)
  5670.     
  5671.     
  5672.     ARGUMENTS:
  5673.     
  5674.         window  - Pointer to WCB for an open window
  5675.     
  5676.     
  5677.     RETURN VALUE:
  5678.     
  5679.         None
  5680.     
  5681.     
  5682.     DESCRIPTION:
  5683.     
  5684.           The "wcleow" function clears the active window  from  the  current
  5685.        position to the end of the window.
  5686.     
  5687.           The "w_cleow"  function  clears  the  specified  window  from  the
  5688.        current position to the end of the window.
  5689.     
  5690.     
  5691.     EXAMPLES:
  5692.     
  5693.         wgotoxy(0, 10);         /* position at line 11 */
  5694.         wcleos();               /* Clear lower part of screen */
  5695.     WCLOSE                                                           WCLOSE
  5696.     W_CLOSE                                                         W_CLOSE
  5697.     
  5698.     
  5699.     
  5700.     PROTOTYPE:
  5701.     
  5702.         wclose()
  5703.         w_close(char *window)
  5704.     
  5705.     
  5706.     ARGUMENTS:
  5707.     
  5708.         window  - Pointer to WCB for an open window
  5709.     
  5710.     RETURN VALUE:
  5711.     
  5712.         None
  5713.     
  5714.     
  5715.     DESCRIPTION:
  5716.     
  5717.           The "wclose" function closes the "active" window, and de-activates
  5718.        it.
  5719.     
  5720.           The  "w_close"  function  closes   the   specified   window,   and
  5721.        de-activates it.
  5722.     
  5723.           If the window being closed is the "active"  window,  the  "active"
  5724.        window will revert to the window which was "active" at the time  that
  5725.        the window being closed was opened.
  5726.     
  5727.     
  5728.     EXAMPLES:
  5729.     
  5730.         wclose();       /* Close active window */
  5731.         w_close(title); /* Close the title window */
  5732.     WCLWIN                                                           WCLWIN
  5733.     W_CLWIN                                                         W_CLWIN
  5734.     
  5735.     
  5736.     
  5737.     PROTOTYPE:
  5738.     
  5739.         wclwin()
  5740.         w_clwin(char *window)
  5741.     
  5742.     
  5743.     ARGUMENTS:
  5744.     
  5745.         window  - Pointer to WCB for an open window
  5746.     
  5747.     
  5748.     RETURN VALUE:
  5749.     
  5750.         None
  5751.     
  5752.     
  5753.     DESCRIPTION:
  5754.     
  5755.           The "wclwin" function clears the entire active window  and  resets
  5756.        the cursor position to the top left hand corner.
  5757.     
  5758.           The "w_clwin" function clears the  entire  specified  window,  and
  5759.        resets the cursor position to the top left hand corner.
  5760.     
  5761.     
  5762.     EXAMPLES:
  5763.     
  5764.         if(c = 0x1b) {          /* Escape command */
  5765.             wclwin();           /* Clear the screen */
  5766.             wputs("Exiting back to main menu");
  5767.             return; }
  5768.     WCURSOR_BLOCK                                             WCURSOR_BLOCK
  5769.     
  5770.     
  5771.     
  5772.     PROTOTYPE:
  5773.     
  5774.         wcursor_block()
  5775.     
  5776.     
  5777.     ARGUMENTS:
  5778.     
  5779.         None
  5780.     
  5781.     
  5782.     RETURN VALUE:
  5783.     
  5784.         None
  5785.     
  5786.     
  5787.     DESCRIPTION:
  5788.     
  5789.           This function enables (turns on) display of the cursor on the  IBM
  5790.        PC video display. The cursor is shown as  flashing  block,  occupying
  5791.        the entire character window.
  5792.     
  5793.     
  5794.     EXAMPLES:
  5795.     
  5796.         if(insert)              /* Test insert mode flag */
  5797.             wcursor_block();    /* Indicate inserting with block cursor */
  5798.         else
  5799.             wcursor_line();     /* Indicate overwrite with line cursor */
  5800.     WCURSOR_LINE                                               WCURSOR_LINE
  5801.     
  5802.     
  5803.     
  5804.     PROTOTYPE:
  5805.     
  5806.         wcursor_line()
  5807.     
  5808.     
  5809.     ARGUMENTS:
  5810.     
  5811.         None
  5812.     
  5813.     
  5814.     RETURN VALUE:
  5815.     
  5816.         None
  5817.     
  5818.     
  5819.     DESCRIPTION:
  5820.     
  5821.           This function enables (turns on) display of the cursor on the  IBM
  5822.        PC video display. The cursor is shown as a single flashing  line,  at
  5823.        the bottom of the character window.
  5824.     
  5825.     
  5826.     EXAMPLES:
  5827.     
  5828.         wcursor_line();     /* Re-enable the cursor */
  5829.         exit(0);            /* And terminate */
  5830.     WCURSOR_OFF                                                 WCURSOR_OFF
  5831.     
  5832.     
  5833.     
  5834.     PROTOTYPE:
  5835.     
  5836.         wcursor_off()
  5837.     
  5838.     
  5839.     ARGUMENTS:
  5840.     
  5841.         None
  5842.     
  5843.     
  5844.     RETURN VALUE:
  5845.     
  5846.         None
  5847.     
  5848.     
  5849.     DESCRIPTION:
  5850.     
  5851.           This function inhibits (turns off) display of the  cursor  on  the
  5852.        IBM PC video display. This affects the cursor  display  only,  screen
  5853.        output will continue to be displayed at the correct cursor position.
  5854.     
  5855.     
  5856.     EXAMPLES:
  5857.     
  5858.         wclscr();           /* Clear screen */
  5859.         wcursor_off();      /* Inhibit cursor */
  5860.         wmenu(10, 10, 0x6007, main_menu, &index); /* Present main menu */
  5861.     WFORM                                                             WFORM
  5862.     
  5863.     
  5864.     
  5865.     PROTOTYPE:
  5866.     
  5867.         register wform(int x, int y, int attrs, char *prompts[],
  5868.                        char *strings,  ...)
  5869.     
  5870.     
  5871.     ARGUMENTS:
  5872.     
  5873.         x       - Absolute COLUMN of upper left corner of form window
  5874.         y       - Absolute ROW    of upper left corner of form window
  5875.         attrs   - Attributes for form window (See WOPEN)
  5876.         prompts - Prompt string for form entries
  5877.         strings - Destination string to receive form data
  5878.         ...     - Additional arguments may be required
  5879.     
  5880.     
  5881.     RETURN VALUE:
  5882.     
  5883.         None
  5884.     
  5885.     
  5886.     DESCRIPTION:
  5887.     
  5888.           The "wform" function opens  a  window,  which  contains  a  "form"
  5889.        consisting of prompts and data areas. Each data area is shown  beside
  5890.        its corresponding prompt, and may be edited using the keys  supported
  5891.        by WGETS. the UP and DOWN ARROW keys may be used to move the  editing
  5892.        cursor between the various fields in the input form.*
  5893.     
  5894.           The "attrs" argument contains the open attributes (see WOPEN)  for
  5895.        the menu window, and may  be  used  to  control  the  color,  border,
  5896.        clearing, etc.
  5897.     
  5898.           The "prompts" argument is an array of pointers to  strings,  which
  5899.        define the prompts and input  fields  in  the  form.  The  first  two
  5900.        characters of each string define the 'X' and 'Y'  coordinates  within
  5901.        the window of the prompt string. The  third  character  contains  the
  5902.        length of the destination string, and the  remainder  of  the  string
  5903.        contains the text prompt. The destination string is positioned in the
  5904.        window directly following the prompt string.  This  list  of  prompts
  5905.        must end with a NULL (0) element.
  5906.     
  5907.           The first (0) element of "prompts" does not actually point  to  an
  5908.        input definition, but contains the X and Y sizes for the window to be
  5909.        opened (High byte = X, Low byte = Y).
  5910.     
  5911.           Following the "prompts" argument, there must  be  one  destination
  5912.        "string" argument for each prompt defined. The strings must  be  long
  5913.        enough to contain the number of characters  specified  in  the  third
  5914.        byte of the coresponding "prompt" string.
  5915.           Only the lower seven bits of the field length are used  (length  =
  5916.        1-127), the high bit indicates that the field is to  contain  numbers
  5917.        only. In this case, the corresponding argument is NOT a pointer to  a
  5918.        string, but must be a pointer to an "int" variable.
  5919.     
  5920.           The form is exited by pressing the ESCAPE key.
  5921.     
  5922.     
  5923.     
  5924.     EXAMPLES:
  5925.     
  5926.         /* Sample input form */
  5927.             char *form[] = {
  5928.                 50<<8|6,        /* Place in 50 by 6 window */
  5929.                 "\x01\x00\x20Software  :",
  5930.                 "\x01\x01\x20Author    :",
  5931.                 "\x01\x02\x20Directory :",
  5932.                 "\x01\x03\x20Filename  :",
  5933.                 0 };
  5934.     
  5935.         /* Data areas for input form */
  5936.             char software[0x21] = "MICRO-C",
  5937.                 author[0x21]    = "Dave Dunfield",
  5938.                 direct[0x21]    = "C:\\MC",
  5939.                 filename[0x21]  = "MC*.*";
  5940.     
  5941.         /* Simple main program to display the form */
  5942.         main()
  5943.         {
  5944.             wform(15, 9, 0xE007, form, software, author, direct, filename);
  5945.         }
  5946.     WGETC                                                             WGETC
  5947.     W_GETC                                                           W_GETC
  5948.     
  5949.     
  5950.     
  5951.     PROTOTYPE:
  5952.     
  5953.         int wgetc()
  5954.         int w_getc(char *window)
  5955.     
  5956.     
  5957.     ARGUMENTS:
  5958.     
  5959.         window  - Pointer to WCB for an open window
  5960.     
  5961.     
  5962.     RETURN VALUE:
  5963.     
  5964.         0-127   - ASCII value of key pressed
  5965.         < 0     - Special function key as defined in "video.h"
  5966.     
  5967.     
  5968.     DESCRIPTION:
  5969.     
  5970.           The "wgetc" function waits until a key is pressed  on  the  system
  5971.        console, and returns its value. The cursor is updated to be placed at
  5972.        the current cursor position in the active window.
  5973.     
  5974.           The "w_getc" function waits until a key is pressed on  the  system
  5975.        console, and returns its value. The cursor is updated to be placed at
  5976.        the current cursor position in the specified window.
  5977.     
  5978.           Note that due to the  buffering  of  the  IBM-PC  keyboard,  every
  5979.        keypress will be reported, even if the WGETC or  W_GETC  function  is
  5980.        called after a key is pressed and released.
  5981.     
  5982.     
  5983.     EXAMPLES:
  5984.     
  5985.         switch(wgetc()) {       /* Handle input keys
  5986.                 . . .
  5987.         }
  5988.     WGETS                                                             WGETS
  5989.     
  5990.     
  5991.     
  5992.     PROTOTYPE:
  5993.     
  5994.         int wgets(int x, int y, char *string, int length)
  5995.     
  5996.     
  5997.     ARGUMENTS:
  5998.     
  5999.         x       - COLUMN position for input
  6000.         y       - ROW    position for input
  6001.         string  - Destination string
  6002.         length  - Length of string (High bit set = Numbers only)
  6003.     
  6004.     
  6005.     RETURN VALUE:
  6006.     
  6007.         Character causing exit
  6008.     
  6009.     
  6010.     DESCRIPTION:
  6011.     
  6012.           The "wgets" function positions the cursor at the specified X and Y
  6013.        coordinates, and displays the contents of "string"  (in  a  field  of
  6014.        "length" characters), and waits for input, which may be used to  edit
  6015.        the string.
  6016.     
  6017.           Any normal ASCII characters which are input will be  entered  into
  6018.        the string, The following function keys are recognized:
  6019.     
  6020.             LEFT ARROW          - Position cursor one space to the left
  6021.             RIGHT ARROW         - Position cursor one space to the right
  6022.             BACKSPACE           - Backup cursor & delete previous character
  6023.             DELETE              - Delete character under cursor
  6024.             INSERT              - Toggle between INSERT/OVERWRITE
  6025.             HOME                - Position cursor at start of string
  6026.             END                 - Position cursor at end of scring
  6027.             PAGE UP             - Clear entire field
  6028.             PAGE DOWN           - Clear from cursor to end of field
  6029.     
  6030.           Any other special function keys will cause "wgets"  to  terminate,
  6031.        and return the value of the offending key. (See  "window.h"  for  key
  6032.        definitions).
  6033.     
  6034.           When INSERT mode is enabled, all entered  text  will  be  inserted
  6035.        into the string, with the remainder of the  string  shifting  to  the
  6036.        right. This mode is indicated by a flashing BLOCK cursor.
  6037.     
  6038.           When OVERWRITE mode is enabled, all entered  text  will  overwrite
  6039.        the existing string. This  mode  is  indicated  by  a  flashing  LINE
  6040.        cursor.
  6041.     
  6042.     
  6043.     EXAMPLES:
  6044.     
  6045.         wgets(2, 5, name, 25);
  6046.     WGOTOXY                                                         WGOTOXY
  6047.     W_GOTOXY                                                       W_GOTOXY
  6048.     
  6049.     
  6050.     
  6051.     PROTOTYPE:
  6052.     
  6053.         wgotoxy(int x, int y)
  6054.         w_gotoxy(int x, int y, char *window)
  6055.     
  6056.     
  6057.     ARGUMENTS:
  6058.     
  6059.         x       - New COLUMN
  6060.         y       - New ROW
  6061.         window  - Pointer to WCB for an open window
  6062.     
  6063.     
  6064.     RETURN VALUE:
  6065.     
  6066.         None
  6067.     
  6068.     
  6069.     DESCRIPTION:
  6070.     
  6071.           The "wgotoxy" function positions  the  cursor  within  the  active
  6072.        window. Any further display output to that window will occur  at  the
  6073.        new ROW and COLUMN positions.
  6074.     
  6075.           The "w_gotoxy" function positions the cursor within the  specified
  6076.        window. Any further display output to that window will occur  at  the
  6077.        new ROW and COLUMN positions.
  6078.     
  6079.     
  6080.     EXAMPLES:
  6081.     
  6082.         for(i=0; i<10; ++i) {   /* Draw a diagonal line of 'X's */
  6083.             wgotoxy(i, i);
  6084.             wputc('X'); }
  6085.     WMENU                                                             WMENU
  6086.     
  6087.     
  6088.     
  6089.     PROTOTYPE:
  6090.     
  6091.         wmenu(int x, int y, int attrs, char *names[], int &index)
  6092.     
  6093.     
  6094.     ARGUMENTS:
  6095.     
  6096.         x       - Absolute COLUMN of top left corner of menu window
  6097.         y       - Absolute ROW    of top left corner of menu window
  6098.         attrs   - Attributes for menu window (see WOPEN)
  6099.         names   - Array to menu selection text (last entry = 0)
  6100.         index   - Address of message selection index variable
  6101.     
  6102.     
  6103.     RETURN VALUE:
  6104.     
  6105.         0   - Selection was made and ENTER pressed.
  6106.         !0  - Menu was aborted via ESCAPE key.
  6107.     
  6108.     
  6109.     DESCRIPTION:
  6110.     
  6111.           The "wmenu" function opens a window  containing  a  list  of  menu
  6112.        items at the specified ROW and COLUMN address. The user may  use  the
  6113.        UP, DOWN, HOME and END keys to select an entry by moving the  INVERSE
  6114.        VIDEO selection cursor. Pressing an alpha-numeric key  will  position
  6115.        the  selection  bar  to  the  first  entry  which  begins  with  that
  6116.        character.
  6117.     
  6118.           When the desired selection is under the cursor, the  selection  is
  6119.        made by pressing the ENTER key.
  6120.     
  6121.           At any time the menu selection may be  canceled  by  pressing  the
  6122.        ESCAPE key.
  6123.     
  6124.           The "attrs" argument contains the open attributes (see WOPEN)  for
  6125.        the menu window, and may  be  used  to  control  the  color,  border,
  6126.        clearing, etc.
  6127.     
  6128.           The "names" argument must be a pointer to an  array  of  character
  6129.        strings which are the selections to display. This array MUST end with
  6130.        a NULL (0) element to indicate the end of the list.
  6131.     
  6132.           The "index" argument is the address of  an  "int"  variable  which
  6133.        contains the position of the selection cursor. It controls where  the
  6134.        selection cursor will appear when the function is first invoked (0  =
  6135.        first entry), and also is assigned  the  position  of  the  selection
  6136.        cursor when the selection is made.
  6137.     
  6138.           Once a selection is made, the first character  of  that  selection
  6139.        will be hilighted in reverse video.
  6140.     
  6141.     
  6142.     
  6143.     
  6144.     EXAMPLES:
  6145.     
  6146.         char *names[] = { "One", "Two", "Three", "Four", "Five", 0 };
  6147.             . . .
  6148.         index = 0;
  6149.         if(wmenu(10, 10, 0xE007, names, &index))
  6150.             return;         /* Aborted, exit to higher level */
  6151.         switch(index) {     /* Handle selection */
  6152.             . . .
  6153.         }
  6154.     WOPEN                                                             WOPEN
  6155.     
  6156.     
  6157.     
  6158.     PROTOTYPE:
  6159.     
  6160.         char *wopen(int x, int y, int width, int height, int attrs)
  6161.     
  6162.     
  6163.     ARGUMENTS:
  6164.     
  6165.         x       - Absolute COLUMN of top left corner of window
  6166.         y       - Absolute ROW    of top left corner of window
  6167.         width   - The width of the window in characters
  6168.         height  - The height of the window in characters
  6169.         attrs   - The window attributes, BIT definitions:
  6170.                     15 - Enable SAVE/RESTORE screen under window
  6171.                 *   14 - Enable SINGLE line BORDER
  6172.                 *   13 - Enable DOUBLE line BORDER
  6173.                     12 - Enable CLEAR on OPEN
  6174.                 **  11 - Enable CLEAR on CLOSE
  6175.                 *** 10 - Disable NEWLINE (LF only)
  6176.                      9 - Enable SCROLLING in window
  6177.                      8 - Enable LINE WRAP in window
  6178.                    7-0 - Video attributes for window
  6179.     
  6180.             *   When BORDER is selected, window will include an enclosing
  6181.                 BOX. In this case, the effective height and width of the
  6182.                 active region (where text data can be written) will be
  6183.                 reduced by 2.
  6184.     
  6185.             **  Has no visual effect when SAVE/RESTORE is enabled.
  6186.     
  6187.             *** If this BIT is set, CTRL-J will behave as LINEFEED only,
  6188.                 and will not return the cursor to the left margin.
  6189.     
  6190.     RETURN VALUE:
  6191.     
  6192.         A pointer to the WCB for the newly opened window
  6193.         0 if the window could not be opened
  6194.     
  6195.     
  6196.     DESCRIPTION:
  6197.     
  6198.           The "wopen" function creates a new window on the PC video  screen.
  6199.        This newly created window is also made the "active" window, which  is
  6200.        automatically accessed by many of the windowing functions.
  6201.     
  6202.           If "wopen" is unable to allocate  enough  memory  for  the  window
  6203.        control block (WCB), it will fail and return a value of zero (0).
  6204.     
  6205.     
  6206.     EXAMPLES:
  6207.     
  6208.         /* Create a title window at top of screen */
  6209.         titlewin = wopen(0, 0, 80, 3, 0x6047);
  6210.     WPRINTF                                                         WPRINTF
  6211.     W_PRINTF                                                       W_PRINTF
  6212.     
  6213.     
  6214.     
  6215.     PROTOTYPE:
  6216.     
  6217.         register wprintf(char *format, arg, ...)
  6218.         register w_printf(char *window, char *format, arg, ...)
  6219.     
  6220.     
  6221.     ARGUMENTS:
  6222.     
  6223.         window  - Pointer to WCB for an open window
  6224.         format  - Pointer to format string
  6225.         arg     - Argument as determined by format string
  6226.         ...     - Additional arguments may be required
  6227.     
  6228.     
  6229.     RETURN VALUE:
  6230.     
  6231.         None
  6232.     
  6233.     
  6234.     DESCRIPTION:
  6235.     
  6236.           The "wprintf" function performs exactly as the  "PRINTF"  function
  6237.        in the standard function library, except that it outputs directly  to
  6238.        the active window using the low level windowing library functions.
  6239.     
  6240.           The "w_printf" function behaves similar to "wprintf", except  that
  6241.        the window to receive the output is specified as the first parameter.
  6242.     
  6243.           These functions should be used  in  preference  to  "PRINTF"  when
  6244.        using the windowing function library since "PRINTF" will not move the
  6245.        windowing librarys cursor, will not use the attributes from the  WCB,
  6246.        and will not respect the boundarys of the window.
  6247.     
  6248.           NOTE: This function uses a variable number of arguments, and  must
  6249.        be declared as "register" (See "window.h").
  6250.     
  6251.     
  6252.     EXAMPLES:
  6253.     
  6254.         wgotoxy(0, 0);
  6255.         wprintf("Window %u", screen);
  6256.     WPUTC                                                             WPUTC
  6257.     W_PUTC                                                           W_PUTC
  6258.     
  6259.     
  6260.     
  6261.     PROTOTYPE:
  6262.     
  6263.         wputc(int c)
  6264.         wputc(int c, char *window)
  6265.     
  6266.     
  6267.     ARGUMENTS:
  6268.     
  6269.         c       - Character to be written to window
  6270.     
  6271.     
  6272.     RETURN VALUE:
  6273.     
  6274.         None
  6275.     
  6276.     
  6277.     DESCRIPTION:
  6278.     
  6279.           This "wputc" function displays a character in the active window at
  6280.        the current cursor position.
  6281.     
  6282.           The "w_putc" functino displays a character in the specified window
  6283.        at the current cursor position.
  6284.     
  6285.           Characters are output in "tty" fashion, with  proper  handling  of
  6286.        control codes such as CARRIAGE-RETURN, LINE-FEED and BELL. The screen
  6287.        will scroll upwards when a NEWLINE is printed on the bottom  line  of
  6288.        the screen, or  when  the  bottom  line  wraps  around  to  the  next
  6289.        (Assuming those options are enabled in the window).
  6290.     
  6291.           Although only the lower 8 bits of a passed value are used, "vputc"
  6292.        will not perform ANY output translations if any of the upper  8  bits
  6293.        are set. This provides a method of displaying  the  video  characters
  6294.        represented by control codes such as NEWLINE, and BACKSPACE.
  6295.     
  6296.           The first byte of the window control block (WCB)  for  the  window
  6297.        contains the attributes which will be used to display the  character.
  6298.        This value is written to the attribute location associated  with  the
  6299.        character on the video display hardware. Its effect is  dependant  on
  6300.        the video  adapter  in  use.  The  "window.h"  header  file  contains
  6301.        definitions of the attribute bits for use  on  "standard"  monochrome
  6302.        and color displays.
  6303.     
  6304.     
  6305.     EXAMPLES:
  6306.     
  6307.         w_putc(0x0A, window1);      /* Line-feed, advance cursor */
  6308.         wputc(0x0A | 0xff00);       /* Display 0x0A character code */
  6309.     WPUTF                                                             WPUTF
  6310.     
  6311.     
  6312.     
  6313.     PROTOTYPE:
  6314.     
  6315.         wputf(char *string, int width)
  6316.     
  6317.     
  6318.     ARGUMENTS:
  6319.     
  6320.         string  - Pointer to character string
  6321.         width   - Width of output field
  6322.     
  6323.     
  6324.     RETURN VALUE:
  6325.     
  6326.         None
  6327.     
  6328.     
  6329.     DESCRIPTION:
  6330.     
  6331.           The "wputf" function outputs a  character  string  to  the  active
  6332.        window screen using the video library functions.
  6333.     
  6334.           The string is left justified in a field of the specified width. If
  6335.        the string is shorter than "width", the field is padded with  blanks.
  6336.        If the string is longer than "width", the output is truncated.
  6337.     
  6338.     
  6339.     EXAMPLES:
  6340.     
  6341.         wputf(message, 10); 
  6342.     WPUTS                                                             WPUTS
  6343.     W_PUTS                                                           W_PUTS
  6344.     
  6345.     
  6346.     
  6347.     PROTOTYPE:
  6348.     
  6349.         wputs(char *string)
  6350.         w_puts(char *string, char *window)
  6351.     
  6352.     
  6353.     ARGUMENTS:
  6354.     
  6355.         string  - Pointer to character string
  6356.         window  - Pointer to WCB for an open window
  6357.     
  6358.     
  6359.     RETURN VALUE:
  6360.     
  6361.         None
  6362.     
  6363.     
  6364.     DESCRIPTION:
  6365.     
  6366.           The "wputs" function outputs a  character  string  to  the  active
  6367.        window.
  6368.     
  6369.           The "w_puts" function output a character string to  the  specified
  6370.        window.
  6371.     
  6372.     
  6373.     EXAMPLES:
  6374.     
  6375.         wputs(message);
  6376.         w_puts(message, window1);
  6377.     WTSTC                                                             WTSTC
  6378.     W_TSTC                                                           W_TSTC
  6379.     
  6380.     
  6381.     
  6382.     PROTOTYPE:
  6383.     
  6384.         int wtstc()
  6385.         int w_tstc(char *window)
  6386.     
  6387.     
  6388.     ARGUMENTS:
  6389.     
  6390.         window  - Pointer to WCB for an open window
  6391.     
  6392.     
  6393.     RETURN VALUE:
  6394.     
  6395.         0       - No key pressed
  6396.         1-127   - ASCII value of key pressed
  6397.         < 0     - Special function key as defined in "video.h"
  6398.     
  6399.     
  6400.     DESCRIPTION:
  6401.     
  6402.           The "wtstc" function  tests  for  a  key  pressed  on  the  system
  6403.        console, and returns its value. If a character is found,  the  cursor
  6404.        is updated in the active window.
  6405.     
  6406.           The "w_tstc" function tests  for  a  key  pressed  on  the  system
  6407.        console, and returns its value. If a character is found,  the  cursor
  6408.        is updated in the specified window.
  6409.     
  6410.           A returned value of zero (0) indicates that no key was found to be
  6411.        pressed.
  6412.     
  6413.           Note that due to the  buffering  of  the  IBM-PC  keyboard,  every
  6414.        keypress will be reported, even if the WTSTC or  W_TSTC  function  is
  6415.        called after a key is pressed and released.
  6416.     
  6417.     
  6418.     EXAMPLES:
  6419.     
  6420.         if(wtstc() == 0x1B) /* exit loop on ESCAPE key */
  6421.             break;
  6422.     WUPDATEXY                                                     WUPDATEXY
  6423.     W_UPDATEXY                                                   W_UPDATEXY
  6424.     
  6425.     
  6426.     
  6427.     PROTOTYPE:
  6428.     
  6429.         wupdatexy()
  6430.         w_updatexy(char *window)
  6431.     
  6432.     
  6433.     ARGUMENTS:
  6434.     
  6435.         window  - Pointer to WCB for an open window
  6436.     
  6437.     
  6438.     RETURN VALUE:
  6439.     
  6440.         None
  6441.     
  6442.     
  6443.     DESCRIPTION:
  6444.     
  6445.           The "wupdatexy" function updates the real X/Y cursor  position  on
  6446.        the video screen to reflect the "logical"  position  where  the  next
  6447.        character will be output in the active window.
  6448.     
  6449.           The "w_updatexy" function updates the real X/Y cursor position  on
  6450.        the video screen to reflect the "logical"  position  where  the  next
  6451.        character will be output in the specified window.
  6452.     
  6453.           The MICRO-C Windowing library uses a BIOS interrupt  (INT  10)  to
  6454.        position the cursor, which is quite slow, compared to  the  speed  of
  6455.        the library video routines. To prevent this  from  slowing  down  the
  6456.        video output, the cursor is  only  physically  re-positioned  when  a
  6457.        "wgotoxy" or a "wgetc" is executed.
  6458.     
  6459.           This allows the library routines to run at full speed,  and  still
  6460.        put the cursor in the right place when  output  stops  and  an  input
  6461.        request is made.
  6462.     
  6463.           A side effect of this is that the cursor on the  screen  will  not
  6464.        appear to move unless  you  call  "wgotoxy"  or  "wgetc".  This  only
  6465.        affects the physical cursor on the screen, MICRO-C maintains its  own
  6466.        internal cursor location which it uses  to  determine  where  on  the
  6467.        screen the next write will occur.
  6468.     
  6469.           Some applications which run in  real  time  (Such  as  a  terminal
  6470.        emulator) do not call "wgetc", but use "wtstc" to poll  the  keyboard
  6471.        on a regular basis. In this case, the "wupdatexy" routine  should  be
  6472.        called any time that the visual position of the cursor is important.
  6473.     
  6474.     
  6475.     EXAMPLES:
  6476.     
  6477.         wupdatexy();        /* position the cursor *
  6478.         c = wtstc();        /* Test for a character */
  6479.  
  6480.  
  6481.  
  6482.                                 MICRO-C Library
  6483.  
  6484.                                TABLE OF CONTENTS
  6485.  
  6486.  
  6487.                                                                          Page
  6488.  
  6489.      1. THE MICRO-C LIBRARIES                                               1
  6490.  
  6491.         1.1 STANDARD Library                                                2
  6492.         1.2 IBM-PC/MS-DOS Library                                           3
  6493.         1.3 IBM-PC WINDOWING Library                                        4
  6494.